How can I store many txt files in order to be embedded in the source code without being visible to the user?

58 Views Asked by At

I'm a blind person and I'm trying to create a win form app that aims to help people with visual impairments to learn better the keyboard. There are different levels in this program. such as: match characters, match words and match sentences. Almost I finished everything, but I miss the technique of storing txt files in the source code in order to be invisible to the user in the program files. Any suggestion?

1

There are 1 best solutions below

0
Nanmu Honery On

You can use the StreamWriter method.

https://learn.microsoft.com/en-us/dotnet/api/system.io.streamwriter?view=net-7.0

A complete example:

internal class Program
{
    static void Main(string[] args)
    {
        // Get the directories currently on the C drive.
        DirectoryInfo[] cDirs = new DirectoryInfo(@"c:\").GetDirectories();

        // Write each directory name to a file.
        using (StreamWriter sw = new StreamWriter("Demo.txt"))
        {
            foreach (DirectoryInfo dir in cDirs)
            {
                sw.WriteLine(dir.Name);
            }
        }

        // Read and show each line from the file.
        string line = "";
        using (StreamReader sr = new StreamReader("Demo.txt"))
        {
            while ((line = sr.ReadLine()) != null)
            {
                Console.WriteLine(line);
            }
        }
    }
}