创建和使用c#应用程序文件夹

Cap*_*cha 3 c# directory appdata

我正在创建一个在我手动创建的文件夹中使用照片和XML文件的应用程序,我想让用户通过应用程序在运行时更新该文件夹的数据(添加照片和编辑Xml文件)我的问题是什么是最好的方法以及放置该文件夹的位置,我知道我必须放置相对路径所以我很困惑它是在AppData中如果是这样如何做到这一点.

noe*_*cus 6

// Use this to get the common directory
string CommonDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

// And combine it with your own. 
// On Window7 this will return "c:\ProgramData\YourCompany\YourProduct"
string YourDir = Path.Combine(CommonDir, @"YourCompany\YourProduct");

// And create the directory / ensure it exists
System.IO.Directory.CreateDirectory(YourDir);
Run Code Online (Sandbox Code Playgroud)

您可以从系统中获取其他特殊文件夹,例如MyDocumentsDesktop最符合您的需求.