Environment.GetFolderPath returning incorrect address
Why does
string AssignmentTypesFilename = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\SchoolDayManager\Assign开发者_StackOverflow中文版mentTypes.txt";`
always return
"C:\\\Users\\\Travis Michael\\\Documents\\\SchoolDayManager\\\AssignmentTypes.txt"
instead of
"C:\Users\Travis Michael\Documents\SchoolDayManager\AssignmentTypes.txt"?
How do you look at the string? Through the debugger's watch window? In the debugger, strings are sometimes escaped before they are displayed. Try displaying it to the user, through
Console.WriteLine(AssignmentTypesFilename);
or if using a WinForm GUI:
MessageBox.Show(AssignmentTypesFilename);
It should be displayed correctly then.
精彩评论