现在我有:
s = @"/Users/minisquad1/Pictures/";
Run Code Online (Sandbox Code Playgroud)
这在我的电脑上运行得很好。如果我可以访问当前用户的图片文件夹,我会感到更安全,因为现在它显然只能在我的计算机上使用。
我不知道该怎么做,有人有想法吗?我正在寻找类似的东西:
s = @"/Users/%currentuser%/Pictures/";
Run Code Online (Sandbox Code Playgroud)
如何才能做到这一点?
您应该考虑使用Environment.SpecialFolderenum。Environment.SpecialFolder.Personal应该让你获得当前用户的主目录。还有一个MyPictures值可以节省您的打字时间。
string s = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
Run Code Online (Sandbox Code Playgroud)