C# 如何检索以文件路径字符串形式运行RemoteApp的客户端计算机特殊文件夹的路径?

C# 如何检索以文件路径字符串形式运行RemoteApp的客户端计算机特殊文件夹的路径?,c#,remote-access,terminal-services,C#,Remote Access,Terminal Services,最初,当我编写上述代码时,我的印象是我们可以在C:\中创建一个目录进行写入,但据我所知,他们可以访问的唯一位置是mydocuments目录 因此,我知道我可以通过以下方式检索本地环境。SpecialFolder: // Set default workspace directory string initialDirectoryString = @"C:\work\"; // Check if remote session, and get the local drive location if

最初,当我编写上述代码时,我的印象是我们可以在
C:\
中创建一个目录进行写入,但据我所知,他们可以访问的唯一位置是
mydocuments
目录

因此,我知道我可以通过以下方式检索本地
环境。SpecialFolder

// Set default workspace directory
string initialDirectoryString = @"C:\work\";
// Check if remote session, and get the local drive location
if(System.Windows.Forms.SystemInformation.TerminalServerSession) {
    initialDirectoryString = @"\\tsclient\C\work\";
}
问题是如何从客户机检索。我想从服务器上检索路径,并在
\\tsclient\
前面加上前缀(并从
C:
等中删除
),但是如果
我的文档
目录在客户端上与(
V:
而不是
D:
)不同,然后,当我尝试写入该位置时,我将获得一个
访问被拒绝的

是否有一种方法可以指定一个类似于CMD的字符串,您可以在其中使用
%USERPROFILE%/My Documents
,但使用
tsclient

编辑:我发现我可以使用
Environment.ExpandEnvironmentalVariables()
%USERPROFILE%\My Documents
更改为绝对路径

string path = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);

嗨,我在同一条路上。你解决问题了吗?
string MyDocumentsLocation = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\My Documents");