private void CommandMethod(object parameter)
{
string path = @"C:\Users\yu_in\Desktop";
Teststring = Environment.CurrentDirectory;
DirectoryInfo fi = new DirectoryInfo(path);
Teststring2 = fi.FullName;
}
I Can't Understand why Teststring2 = "C:\Users\yu_in\source\repos\TestApplication\TestApplication\bin\x64\Debug\net5.0-windows\C:\Users\yu_in\Desktop" why result add Environment.CurrentDirectory?
There is quite literally more to this question than meets the eye:)
Your path has an additional, invisible, unicode character at the beginning of it: U+202A
(The actual text in your code is: @"[U+202A]C:\Users\yu_in\Desktop"
). This is making your path invalid, so the constructor of DirectoryInfo
is attempting to use your provided path as a local path.
Instead of this: @"C:\Users\yu_in\Desktop"
, use this: @"C:\Users\yu_in\Desktop"
. I know both paths look the same, but only the second one is a valid path.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.