In the following code:
if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/data.dat"))
{
File.AppendAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/data.dat", temp);
}
else
{
File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/data.dat");
File.SetAttributes(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/data.dat", FileAttributes.Hidden);
File.AppendAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/data.dat", temp);
}
for some reason, the first time this code is run, it creates the file just fine, but does not write to it, and it will not until i exit the app, and re-run it. the 2nd, 3rd, and so on runs work just fine, its just the initial that's screwy. any ideas? file names and directories are random since i was just testing something so you should be able to change those to whatever you want if you're testing something. Thanks in advance
File.Create
is returning you stream to file you might want to close it before you try to reopen it again.