Hi all,
i am copying File/folder from one location to another location. i want that if i am copying same file/folder in same location it should create Version of file instead of override the file or folder.
Thnax in avdance
How to do Versioning of file in csharp?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

NarayanRank #8,477 · 221 reputationPosted Apr 9, 2012, 12:52 AM EDT
theLizardRank #1,079 · 1.8K reputationPosted Apr 9, 2012, 1:16 AM EDT
{
public TCopyFile(string file)
{
int i = 1;
string newFile = file, oldFile = file;
string serial;
FileInfo fi = new FileInfo(file);
while (File.Exists(newFile))
{
serial = "_" + i.ToString();
newFile = oldFile.Substring(0, oldFile.IndexOf(".")) + serial + fi.Extension;
i++;
}
File.Copy(oldFile, newFile);
}
}