Storing text files in Visual Studio

2019-09-08 07:12发布

Right now I am reading in text files in my C# code in Visual Studio. The text files are saved onto my computer and whenever we want to run the code on another computer, we have to change the path for the text file within the code so it will work. My question is, is there any place you can save the text files within the project so that you do not have to change the path everytime to run it on different computers?

2条回答
神经病院院长
2楼-- · 2019-09-08 07:31

Add the txt files to the project. Manage them in your source control just like any other file.

You can add any kind of file you like. They just sit there doing nothing ( it doesn't try to compile them or anything), you can group them into folders for better clarity.

查看更多
女痞
3楼-- · 2019-09-08 07:33

You can add a folder to your project to hold the various text files:

  • Right mouse click on your project
  • Select Add New Folder

You can place any type of file into this folder.

Hope this helps.

查看更多
登录 后发表回答