How to write contents of one file to another file?

后端 未结 8 1471
遇见更好的自我
遇见更好的自我 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:26

    Is it necessary to us FileStream? Because you can do this very easily with simple File Class like;

    using System.IO;
    string FileContent = File.ReadAllText(FilePathWhoseTextYouWantToCopy);
    File.WriteAllText(FilePathToWhomYouWantToPasteTheText,FileContent);
    

提交回复
热议问题