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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
theLizardPosted Apr 9, 2012, 5:16 AM
{
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);
}
}
NarayanPosted Apr 9, 2012, 4:52 AM