FileWather Path Error [modified][Solved]
-
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.
modified on Friday, June 12, 2009 8:26 AM
-
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.
modified on Friday, June 12, 2009 8:26 AM
Did you debug to see what is the value in the variables and are they similar to what is expected as Copy params? By the way what is the error? do you get an exception. If yes, which one?
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Did you debug to see what is the value in the variables and are they similar to what is expected as Copy params? By the way what is the error? do you get an exception. If yes, which one?
You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_
-
Yes, I have debugged it and low and behold, I missed it, should not have used
outPath + finfo.FullName
, should have usedoutPath + finfo.Name
. Silly mistake. Thanks anyway.Excellence is doing ordinary things extraordinarily well.
Help others by editing your original post add [solved] to the title and at the end anotate the solution. There are those of flamable nature who might jump at a silly mistake, we all make them, so pre-empt them by telling them.
Panic, Chaos, Destruction. My work here is done.
-
Help others by editing your original post add [solved] to the title and at the end anotate the solution. There are those of flamable nature who might jump at a silly mistake, we all make them, so pre-empt them by telling them.
Panic, Chaos, Destruction. My work here is done.
-
Happiness?? Never seen anybody else do that!!
Excellence is doing ordinary things extraordinarily well.
Thanks. Your original was, as I said, a bit of a silly mistake and in that scenario it is better to tell others that you have realised what you did wrong. If everyone would mark the thread headers with the solutions the forums would be easier to follow.
Panic, Chaos, Destruction. My work here is done.
-
Thanks. Your original was, as I said, a bit of a silly mistake and in that scenario it is better to tell others that you have realised what you did wrong. If everyone would mark the thread headers with the solutions the forums would be easier to follow.
Panic, Chaos, Destruction. My work here is done.