Copy Text File With Unique Name

Posted by Lakhangarg under C# category on | Views : 1808
using System.IO;
Random objRandom = new Random();
string SourceFilePath=Server.MapPath("TextFile.txt");
string DestinationFilePath=Server.MapPath(".").ToString()+objRandom.Next().ToString()+".txt";
File.Copy(SourceFilePath, DestinationFilePath);

Random objRandom = new Random();
This class is used to Create Random Number
each time this will return a unique number.
Use File.Copy to Copy the Content of one file to other and save the new file.

Comments or Responses

Login to post response