Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. FileWather Path Error [modified][Solved]

FileWather Path Error [modified][Solved]

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MumbleB
    wrote on last edited by
    #1

    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

    _ 1 Reply Last reply
    0
    • M MumbleB

      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

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      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_

      M 1 Reply Last reply
      0
      • _ _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_

        M Offline
        M Offline
        MumbleB
        wrote on last edited by
        #3

        Yes, I have debugged it and low and behold, I missed it, should not have used outPath + finfo.FullName, should have used outPath + finfo.Name. Silly mistake. Thanks anyway.

        Excellence is doing ordinary things extraordinarily well.

        N 1 Reply Last reply
        0
        • M MumbleB

          Yes, I have debugged it and low and behold, I missed it, should not have used outPath + finfo.FullName, should have used outPath + finfo.Name. Silly mistake. Thanks anyway.

          Excellence is doing ordinary things extraordinarily well.

          N Offline
          N Offline
          Nagy Vilmos
          wrote on last edited by
          #4

          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.

          M 1 Reply Last reply
          0
          • N Nagy Vilmos

            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.

            M Offline
            M Offline
            MumbleB
            wrote on last edited by
            #5

            Happiness?? Never seen anybody else do that!!

            Excellence is doing ordinary things extraordinarily well.

            N 1 Reply Last reply
            0
            • M MumbleB

              Happiness?? Never seen anybody else do that!!

              Excellence is doing ordinary things extraordinarily well.

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #6

              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.

              M 1 Reply Last reply
              0
              • N Nagy Vilmos

                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.

                M Offline
                M Offline
                MumbleB
                wrote on last edited by
                #7

                I did that in my reply. I mentioned exactly what I did wrong and rectified it.

                Excellence is doing ordinary things extraordinarily well.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups