我正在尝试找出一种使用 C# 导航到漫游中的子文件夹的方法。我知道访问我可以使用的文件夹:
string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
我想做的是导航到 Roaming 中的一个文件夹,但不知道如何操作。我基本上需要做这样的事情:
string insideroaming = string folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData\FolderName);
有什么办法吗?谢谢。
请您参考如下方法:
考虑 Path.Combine :
string dir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"FolderName"
);
它返回类似于:
C:\Users\<UserName>\AppData\Roaming\FolderName
如果需要获取文件夹内的文件路径,可以试试
string filePath = Path.Combine(
dir,
"File.txt"
);
或者只是
string filePath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"FolderName",
"File.txt"
);
