简体   繁体   中英

.NET 4's System.IO.File.Copy and encoding of Unicode file names

I use this line of code to copy a file from sourcePath to destinationPath.

System.IO.File.Copy(sourcePath , destinationPath);

It works perfectly, but when my destinationPath includes unicode characters, I get them replaced by other characters. For example if my path is:

/Övrigt/År2016.doc

I get /Ívrigt/+r2016.doc copied on my disk. Is there any way to handle this problem?

Thanks.

I've tried to recreate the issue you were having but I'm unable to. I was using the following similar to you provided in .Net 4.0:

System.IO.File.Copy("C:/temp/Övrigt/År2016.doc", "C:/temp/Ívrigt/År2016.doc");

This gave me the correct files as expected in the correct locations.

Would you be doing anything with the sourcePath or destinationPath before they get passed into the Copy method? Where and how are those variables determined?

Could you give any more info to the problem?

Thanks.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM