ririri-2352 avatar image
0 Votes"
ririri-2352 asked JackJJun-MSFT commented

File.Copy method error

When you copy a file using the copy method in c#, the file is created, but there is a situation where it is copied without content.
What are the causes of this problem?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ririri-2352, Welcome to Microsoft Q&A, based on my test, File.Copy method works for me.
Please check if you use the same code with the following:

 string path1 = @"C:\Users\username\Desktop\test.xml";
 string path2 = @"C:\Users\username\Desktop\new.xml";
 File.Copy(path1, path2);   

Also, you could use FileInfo.CopyTo Method to copy the file.

    FileInfo fi = new FileInfo(path1);  

Therefore, Could you tell me which situation when you will meet the problem?

0 Votes 0 ·

0 Answers