如何使用C#找到漫游内的文件夹?

Xce*_*ist 1 c# directory roaming appdata subdirectory

我正试图找出一种方法,使用C#导航到漫游中的子文件夹.我知道要访问我可以使用的文件夹:

string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Run Code Online (Sandbox Code Playgroud)

我要做的是导航到漫游内的文件夹,但不知道如何.我基本上需要做这样的事情:

string insideroaming = string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData\FolderName);
Run Code Online (Sandbox Code Playgroud)

有什么办法吗?谢谢.

Ale*_*exD 5

考虑Path.Combine:

string dir = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
    "FolderName"
);
Run Code Online (Sandbox Code Playgroud)

它返回类似于:

C:\ Users\< UserName >\AppData\Roaming\FolderName

如果您需要在文件夹中获取文件路径,可以尝试

string filePath = Path.Combine(
    dir,
    "File.txt"
);
Run Code Online (Sandbox Code Playgroud)

要不就

string filePath = Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
    "FolderName",
    "File.txt"
);
Run Code Online (Sandbox Code Playgroud)