我如何读取具有自定义路径的TXT文件,但是“通用”任何计算机用户的路径?
我想在不使用bin/debug
文件夹的情况下阅读文本文件(.txt),因为我必须将项目推入github,我需要我的文本文件(.txt)的路径(.txt)一个是解决方案中的文件夹。路径格式必须适用于任何计算机,我的计算机的完整路径不好。
using (System.IO.StreamReader srr = new System.IO.StreamReader(@"C:\example\example\example\example\example\example\FolderInSolution\highscoreFile.txt"))
displayHighScore.Content = srr.ReadLine();
I would like to read a text file(.txt) without using bin/debug
folder, because I have to push the project into github, and I need a path for my text file(.txt) which one is a folder in the solution. The path format must works for any computer, full path from my computer is not good.
using (System.IO.StreamReader srr = new System.IO.StreamReader(@"C:\example\example\example\example\example\example\FolderInSolution\highscoreFile.txt"))
displayHighScore.Content = srr.ReadLine();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到了为您看到的两个选项,即:
您可以删除大多数文件路径:
I see two options for you, namely:
Then you could remove most of that file path: