You can use function DoesFileExist
and check on while creating new file. If it is already exist then you can write same texts (existing file) with OutputFile
// Check for file existence
bool DoesFileExist(string filename)
{
return File.Exists(Path.Combine(GetCurrentDirectory(),filename));
}
// Get current folder directory
string GetCurrentDirectory()
{
return System.IO.Path.GetDirectoryName(Host.TemplateFile);
}
// Get content of file name
string OutputFile(string filename)
{
using(StreamReader sr =
new StreamReader(Path.Combine(GetCurrentDirectory(),filename)))
{
return sr.ReadToEnd();
}
}
Writing same file:
// Write with original file
fileManager.StartNewFile(fileName);
this.Write(OutputFile(fileName));
You can refer this example Metadata Class or Data Annotation from EDMX Files