如何在 c# 中获得 %LocalAppData%?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1980105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get %LocalAppData% in c#?
提问by Dee
How do I get %LocalAppData%
in C#?
我如何%LocalAppData%
进入 C#?
采纳答案by Kristopher Ives
Environment.GetEnvironmentVariable("LocalAppData")
for C#, since Visual Studio isn't a language, unless you're looking to get that variable in one of the VS dialogs or something.
Environment.GetEnvironmentVariable("LocalAppData")
对于 C#,因为 Visual Studio 不是一种语言,除非您希望在其中一个 VS 对话框或其他东西中获取该变量。
回答by Blake Blackwell
If you would like to use an enumeration, try the following:
如果您想使用枚举,请尝试以下操作:
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
Using this technique, you can also find all other Window's file paths (i.e Program Files, My Documents, etc).
使用这种技术,您还可以找到所有其他 Window 的文件路径(即程序文件、我的文档等)。