如何在c#中获取当前用户的本地设置文件夹路径?

时间:2021-03-05 22:57:48

I want to point a file dialog at a particular folder in the current user's Local Settings folder on Windows. What is the shortcut to get this path?

我想将一个文件对话框指向Windows上当前用户的本地设置文件夹中的一个特定文件夹。得到这条路径的捷径是什么?

3 个解决方案

#1


35  

How about this, for example:

这个怎么样,例如:

String appData = 
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

I don't see an enum for just the Local Settings folder.

我不会只看到本地设置文件夹的enum。

http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx has a list with examples.

http://web.archive.org/web/20080303235606/http:// dotnetjunkies.com/weblog/nenoloje/archive/2007/07/07/07/259223.aspx有一个例子列表。

#2


1  

Environment.GetFolderPath( Environment.SpecialFolders.LocalApplicationData);?

环境。GetFolderPath(Environment.SpecialFolders.LocalApplicationData);?

I can't remember if there is a "Local Settings" folder on Windows XP anymore, it seems vaguely familiar.

我不记得Windows XP上是否还有一个“本地设置”文件夹,它似乎有点熟悉。

#3


1  

string localPath = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)).FullName;

is the simple answer.

是一个简单的答案。

#1


35  

How about this, for example:

这个怎么样,例如:

String appData = 
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

I don't see an enum for just the Local Settings folder.

我不会只看到本地设置文件夹的enum。

http://web.archive.org/web/20080303235606/http://dotnetjunkies.com/WebLog/nenoloje/archive/2007/07/07/259223.aspx has a list with examples.

http://web.archive.org/web/20080303235606/http:// dotnetjunkies.com/weblog/nenoloje/archive/2007/07/07/07/259223.aspx有一个例子列表。

#2


1  

Environment.GetFolderPath( Environment.SpecialFolders.LocalApplicationData);?

环境。GetFolderPath(Environment.SpecialFolders.LocalApplicationData);?

I can't remember if there is a "Local Settings" folder on Windows XP anymore, it seems vaguely familiar.

我不记得Windows XP上是否还有一个“本地设置”文件夹,它似乎有点熟悉。

#3


1  

string localPath = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)).FullName;

is the simple answer.

是一个简单的答案。