किसी मौजूदा फ़ाइल की प्रतिलिपि बनाने के लिए File.Copy पद्धति का उपयोग करें।
उस फ़ाइल का पथ जोड़ें जिसे आप कॉपी करना चाहते हैं।
String myPath = @"D:\one.txt";
अब उपरोक्त फ़ाइल को निम्न फ़ाइल में कॉपी करें -
String myPath = @"D:\one.txt";
स्रोत और गंतव्य फ़ाइल दोनों के साथ File.Copy पद्धति का उपयोग करें।
File.Copy(myPath,newpath);
उदाहरण
using System;
using System.IO;
public class Program {
public static void Main() {
String myPath = @"D:\one.txt";
// the file will get copied here
String newpath = @"D:\two.txt";
// copying file
File.Copy(myPath,newpath);
}
}