I'm writting a small program and I want to get the path of an txt file. I get the path, but there is always a second '\' in the output of the string variable.
For example:
string path = @"C:\Test\Test\Test\"; 
expected output: 'C:\Test\Test\Test\'
Output during debug: 'C:\\Test\\Test\\Test\\'
The same is when I use:
public static readonly string AppRoot = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
When I run my app during DEBUG, the txt file can not be opened, because it steps into the IF part.
Code:
public static readonly string AppRoot = Path . GetDirectoryName (Assembly.GetEntryAssembly().Location);
        FileStream fs;
        StreamReader sr;
        string dateiname = "anleitung.txt";
        string ausgabe;
        string path = Path.Combine(AppRoot, dateiname);
        if (!File.Exists(path))
            {
                MessageBox.Show("Die Datei '" + dateiname + "' existiert nicht!", "Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
        fs = new FileStream(dateiname, FileMode.Open);
        sr = new StreamReader(fs);
        ausgabe = "";
        while (sr.Peek() != -1)
            ausgabe += sr.ReadLine() + "\n";
        sr.Close();
The txt file is stored in the project folder.
The WinForms APP is written in C# with .Net Framework 4.8
Maybe anyone has an idea.
Thank you in advance.