I'm using the following code to copy csv files between folders;
public void button1_Click(object sender, EventArgs e)
{
System.IO.FileSystemWatcher Watcher = new System.IO.FileSystemWatcher();
Watcher.Path = textBox1.Text;
Watcher.Created += new System.IO.FileSystemEventHandler(OnChanged);
Watcher.EnableRaisingEvents = true;
this.WindowState = FormWindowState.Minimized;
MessageBox.Show("File copy between folders is running...");
}
public void OnChanged(object source, FileSystemEventArgs e)
{
try
{
string FileName = e.Name;
string sSource = e.FullPath;
string sDest = textBox2.Text + @"\" + FileName;
System.IO.File.Copy(sSource, sDest);
}
catch
{
return;
}
}
The problem is that the file gets copied over to the new folder, but the data inside the .csv file dissapears.
What causes this?