开发者

Environment.GetFolderPath returning incorrect address

开发者 https://www.devze.com 2023-03-10 15:29 出处:网络
Why does string AssignmentTypesFilename = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @\"\\SchoolDayManager\\Assign开发者_StackOverflow中文版mentTypes.txt\";`

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消