1

I'm using Visual c# 2010 express edition, and I'm working around files a lot, there's writexml and there's filestream for txt write.

The question is, when I press F5 and try out the program it writes the files correctly, but when I close, do the files get deleted?

If I write a file in this way:

Table.WriteXml("tablexml.xml", XmlWriteMode.WriteSchema);    

Where does the file get stored? will the file remain there for reading if i close the program that was running in debugmode (F5) ?

JLRishe
  • 99,490
  • 19
  • 131
  • 169
César Amorim
  • 367
  • 3
  • 16
  • 2
    Nothing like that happens. If you don't delete a file, it doesn't get deleted. If you don't save it, it won't be saved. – John Saunders Apr 22 '14 at 22:55
  • 3
    Seems you could answer this yourself. Change `tablexml.xml` to "MyWierdFileName12345.xml", and run your app. While it's still running, search your hard drive for the filename you used; if you find it, you'll know whether it gets stored or not (and if it does, where). If it's found, stop your app and repeat the search. Is it still there? If so, it doesn't get automatically deleted. – Ken White Apr 22 '14 at 22:58
  • I tried that once, but i couldn't find the file, that's why i'm asking.. it could create temporary files since it's in debug mode – César Amorim Apr 22 '14 at 23:05

2 Answers2

3

The question is, when i press f5 and try out the program it writes the files correctly, but when i close, do the files get deleted?

No. The files are only deleted if you delete them.

where does the file get stored? will the file remain there for reading if i close the program that was running in debugmode (F5) ?

Most generally, when you don't specify paths, files are written in what the process considers its working directory. You can set the working directory with:

System.IO.Directory.SetCurrentDirectory(path);

The working directory for your project can be set in the project settings.

Markus
  • 761
  • 3
  • 6
1

Most likely F5 will compile and run your application and does not delete anything else than the application cache itself.

So your Xml will not be deleted.

Tareffic
  • 121
  • 9