hi all.
i have a .txt-file which is created by a second program
with unity i want to change some lines of my .txt-file but i always get the IOexception error.
dunno whats wrong with my code. tried to google a solution and found different ways of dealing with my problem, but none worked so far.
using UnityEngine;
using System.IO;
public class txtExportieren : MonoBehaviour
{
StreamWriter writer;
StreamReader reader;
string path = "O:/PO/Ablage/13_BEI/Florian Pollok/PlantSocket/asd.txt";
public Vector3 pos;
GameObject[] cubesArray;
public void Button_export()
{
writer = new StreamWriter(path, false)
cubesArray = GameObject.FindGameObjectsWithTag("Plant");
foreach (GameObject Plant in cubesArray)
{
reader = new StreamReader(path);
pos = Plant.transform.position;
var ANAME = Plant.name;
var AX = Mathf.Round(pos[0]);
var AZ = Mathf.Round(pos[2]);
for (var path = reader.ReadLine(); path != null; path = reader.ReadLine())
{
var items = path.Split(' ');
string itemLabel = items[0];
if (items[0] == ANAME)
{
writer.WriteLine(items[0] + ' ' + AX + ' ' + AZ + ' ' + items[3]);
}
reader.Dispose();
writer.Dispose();
writer.Close();
reader.Close();
}
}
}
}
greetz