Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取登录用户';C#wpf中的s文档路径_C#_Wpf - Fatal编程技术网

如何获取登录用户';C#wpf中的s文档路径

如何获取登录用户';C#wpf中的s文档路径,c#,wpf,C#,Wpf,在我的wpf C#应用程序中,我希望获得登录用户的my documents路径。 我使用以下代码 string myDocumentPath = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents"); 但是当以管理员身份运行wpf应用程序时,我使用上述代码获得了管理员的文档路径 这个问题还有其他功能吗? 请提供任何想法或建议。您应该使用Environment.Ge

在我的wpf C#应用程序中,我希望获得登录用户的my documents路径。 我使用以下代码

string myDocumentPath = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents");
但是当以管理员身份运行wpf应用程序时,我使用上述代码获得了管理员的文档路径

这个问题还有其他功能吗?
请提供任何想法或建议。

您应该使用
Environment.GetFolderPath()
获取环境文件夹。特别是,使用
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
,它将为运行应用程序的用户提供“我的文档”(现在简称为“文档”)文件夹