In an application, the user may open saved files. My goal is to check wether a file is already open, and offer the user the possibility to open it again only if a local copy is created, so that the same file cannot be modified at the same time.
The workflow would be as follows:
if (File.Exists(strFileName))
bCreateCopy = AlertBox.Display("File already open. Work on a copy?", true/false);
if (bCreateCopy == true)
{
strNewAutomaticFileName = createAutomaticFileName (sourceFile)
File.Copy(sourceFile, strNewAutomaticFileName );
}
Is there a method that does what I need in 'createAutomaticFileName()
' ?
I was thinking of creating the typical cannonical names:
sourceFile - copy
sourceFile - copy (1)
sourceFile - copy (2)
Is there a better workaround to accomplish this purpose?