Reputation: 350
If I have a file, like a .txt file (not a Resource or Content file) in my project that I want to read/write to at runtime, in a debugging session from Visual Studio, what's the simplest way to do that?
Visual Studio has to hold references to these files' locations in order to load them, right? I want to do the same thing.
I'm planning to have hundreds of these files and don't want to set everything to "Content" and "Copy if Newer" in Visual Studio.
Upvotes: 0
Views: 127
Reputation: 1474
Put all your text files under a folder and read them with following code -
using System.IO;
foreach (string file in Directory.EnumerateFiles(folderPath, "*.txt"))
{
string contents = File.ReadAllText(file);
}
EnumerateFiles
GetFiles
Upvotes: 1