المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : FileWather Path Error



C# Programming
06-12-2009, 04:11 PM
Hi Guys. I have written a Windows Service with a FileWatcher. Now, when there are new files in the directory it picks the files up fine but when it has to copy then out into a new directory I get an error of The given path's format is not supported. Below is the copy function.


try
{
string path = fsw.Path;
string outPath = "C:\\TestDir2\\";
char[] trimchars = new char[] { '.', 't', 'x', 't' };
DirectoryInfo dinfo = new DirectoryInfo(path);
foreach (FileInfo finfo in dinfo.GetFiles("*.*"))
{
File.Copy(finfo.FullName, outPath + finfo.FullName, true);
}
}


It stops on the line: FIle.Copy(finfo.FullName, outPath + finfo.FullName, true);. Anybody have any ideas?

Excellence is doing ordinary things extraordinarily well.