Double the "\" or add @ before the string...
Visual Studio C#: File path error
I have a class GlobalVariables.cs, I have code public static string InstructionFilePath {get; set;}
Now the code for file path does not work (not able to build solution). If I don't use the variable and use file path directly in Process.Start, it will work.
But my question is: How to write the file path correctly for the variable?
It does not seem it serve as the purpose of global variable. Now I have the code GlobalVariables.InstructionFilePath = "C\User\QR\Documents\Instruction.pdf" within one form. If I use the same file path in a different form, should I need to write GlobalVariables.InstructionFilePath = "C\User\QR\Documents\Instruction.pdf" again?
Is it a way to write GlobalVariables.InstructionFilePath = "C\User\QR\Documents\Instruction.pdf" outside a form? But it seems it is also wrong to write it in GlobalVariables.cs
The reason is: If I use C\User\QR\Documents\Instruction.pdf in multiple forms, and I would like to set to it as GlobalVariables.InstructionFilePath, so that I only need to update it in one place (if the file has moved).
Thanks.