My C# application writes its full path surrounded by double quotes to a file, with:
streamWriter.WriteLine("\"" + Application.ExecutablePath + "\"");
Normally it works, the written file contains
"D:\Dev\Projects\MyApp\bin\Debug\MyApp.exe"
But, if the executable path of my application contains a #, something weird happens. The output becomes:
"D:\Dev\Projects#/MyApp/bin/Debug/MyApp.exe"
The slashes after the # become forward slashes. This causes issues with the system I am developing.
Why is this happening, and is there a way to prevent it that is more elegant than string.replacing the path before writing?