可能重复:
How can i get the path of the current user’s “Application Data” folder?
Windows XP Application Data Folder?如何获取应用程序数据文件夹?
我必须保存在应用程序数据的一些设置,但是,当我使用的东西为"@C:\Documents ..."
别人在d运行windous:\那么如何获取该目录?
可能重复:
How can i get the path of the current user’s “Application Data” folder?
Windows XP Application Data Folder?如何获取应用程序数据文件夹?
我必须保存在应用程序数据的一些设置,但是,当我使用的东西为"@C:\Documents ..."
别人在d运行windous:\那么如何获取该目录?
使用DriveInfo类可以使用Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
...
而且还有的exaple,你如何使用它:
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
,它返回类似C:\\Users\\UserName\\ApplicationData
并且您也可以使用Environment.SpecialFolder.Desktop,因此您可以访问实际用户的桌面...
看看这个MSDN项,以获取应用程序的数据目录,Environment.SpecialFolder。
我以前的做法是使用Evironment.SystemDirectory,然后根据我的需要将其分解。但是,如果你所担心的驱动器,然后通过做DriveInfo.GetDrives()
以及[此帖](http://stackoverflow.com/questions/703281/getting-path-relative-to-the-current-working-directory)。 – Brian