How to write contents of one file to another file?

后端 未结 8 1476
遇见更好的自我
遇见更好的自我 2020-12-09 10:46

I need to write contents of a file to another file using File.OpenRead and File.OpenWrite methods. I am unable to figure out how to do it.

How can i modify the follo

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 11:34

    If you are not keen at using Read/Write function of File , you can better try using Copy functionality

    Easiest will be : 
    
          File.Copy(source_file_name, destination_file_name, true)
    

    true--> for overwriting existing file,without "true" it will create a new file.But if the file already exists it will throw exception without "true" argument.

提交回复
热议问题