我为我的游戏创建了一个高分文件,但我在阅读它时遇到了问题。
当我更换电脑时,我的 USB 驱动器将字母 .eg 从驱动器 E 更改为驱动器 G。
这会导致读取文件出现问题。(因为我使用字符串路径 = @"g:\Scores.txt";)
所以我的问题是....我可以设置程序位置的默认路径吗?
我当前的代码:-
string path = @"g:\Scores.txt";
StringBuilder sb = new StringBuilder();
using (StreamReader sr = new StreamReader(path))
{
while (sr.Peek() >= 0)
{
sb.Append(sr.ReadLine());
}
}
任何帮助表示赞赏。