简体   繁体   中英

Saving a file in code - Windows 7

I want to serialize some information I retrieve from the user in a small .NET 3.5 WinForms app to an XML file saved locally on his computer. Currently all the stations of the users intended to use this app have Windows 7 on them.

The thing is that the system won't just let me save the file anywhere, and I need a place that is both accessible through code (the system will allow saving there), and preferably is generic enough so that if tomorrow I want to run this app on a different version of Windows this path will still exist.

Any ideas?

Thank you.

You should be able to write to the local Application Data folder.

You can access it from C# as the Environment.SpecialFolder.LocalApplicationData folder.

Another option would be Environment.SpecialFolder.Personal .

You can have .net give the User's Userpath. Like "C:\\Users\\User\\MyDocuments". Actually, that's what George's link is about. +1 for him.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM