我想保存我的应用程序的日期,但我不知道应用程序是否为不同的用户保存,例如,如果"andy“我不能使用("C:\ users \Game maker\AppData\Roaming"),那么如何在"AppData\Roaming\MaxrayStudyApp”中为任何用户创建文件。
Computer myComputer = new Computer();
myComputer.FileSystem.WriteAllText(@"C:\Users\Game maker\AppData\Roaming\MaxrayStudy\data.txt","", false);发布于 2016-09-15 03:05:29
几乎就是这个的复制品:Environment.SpecialFolder.ApplicationData returns the wrong folder
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);这将获得所需的文件夹,然后使用Path.Combine()写入该文件夹中的一个目录。
var roamingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var filePath = Path.Combine(roamingDirectory, "MaxrayStudy\\data.txt");发布于 2016-09-15 04:39:41
我重启了我的windows,并写下了下面的内容
string filePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
filePath= (filePath+@"\MaxrayStudyApp\data.txt");
string path =Convert.ToString(filePath);
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(filePath,false)){
file.WriteLine(" XP : 0");}https://stackoverflow.com/questions/39497835
复制相似问题