Question on Directory.GetFiles()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Jackson

    #1

    Question on Directory.GetFiles()

    In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFi les(path) to
    get all the files in the directory. However, I'm getting an error regarding
    "Illegal character in Path", even though I can copy, etc the file using the
    Windows XP explorer.

    I can trap the error, but then this traps the entire GetFiles() function,
    not just the one bad file.

    Is there a way to just trap for the one bad file and continue on?

    Michael


  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    RE: Question on Directory.GetFi les()



    "Michael Jackson" wrote:
    In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFi les(path) to
    get all the files in the directory. However, I'm getting an error regarding
    "Illegal character in Path", even though I can copy, etc the file using the
    Windows XP explorer.
    >
    I can trap the error, but then this traps the entire GetFiles() function,
    not just the one bad file.
    >
    Is there a way to just trap for the one bad file and continue on?
    >
    Michael
    >
    >
    It is very likely the path you are sending it is wrong and has the bad
    character.
    >

    Comment

    • Michael Jackson

      #3
      Re: Question on Directory.GetFi les()

      Yes, there is a bad character in one of the paths. Odd thing though, .NET
      fails on it, but I can move, copy, etc through windows. I'm getting a list
      of files from a copy of another hard drive. The file was created and saved
      through Microsoft Word. How can Microsoft Word create a file name that .NET
      cannot access through GetFiles().

      When the GetFiles function encounters a file name with a bad character, the
      function throws an exception, and the String Array being populated by the
      GetFiles function is Nothing.

      I just can't believe this is how Microsoft wrote this function. Why can it
      not AT LEAST give me the files that do not have illegal characters in the
      file name.

      Thanks,

      Michael



      "Family Tree Mike" <FamilyTreeMike @discussions.mi crosoft.comwrot e in
      message news:2BD60678-2DD6-46D4-9671-7E00C85E35D0@mi crosoft.com...
      >
      >
      "Michael Jackson" wrote:
      >
      >In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFi les(path)
      >to
      >get all the files in the directory. However, I'm getting an error
      >regarding
      >"Illegal character in Path", even though I can copy, etc the file using
      >the
      >Windows XP explorer.
      >>
      >I can trap the error, but then this traps the entire GetFiles() function,
      >not just the one bad file.
      >>
      >Is there a way to just trap for the one bad file and continue on?
      >>
      >Michael
      >>
      >>
      >
      It is very likely the path you are sending it is wrong and has the bad
      character.
      >
      >>

      Comment

      • Michael Jackson

        #4
        Re: Question on Directory.GetFi les()

        I'm sorry. I re-read the reply to my question and I see what you are saying
        about passing in a path with an illegal character in it.

        No, that is not the case, because I'm also getting the directories of that
        directory via GetDirectories, and I do that BEFORE the GetFiles function.
        When stepping thru the code in debug, I can see that I'm getting an array of
        Directores.

        Thanks
        Michael


        "Michael Jackson" <michaeldjackso n@suddenlink.ne twrote in message
        news:47684e76$0 $5280$bbae4d71@ news.suddenlink .net...
        In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFi les(path)
        to get all the files in the directory. However, I'm getting an error
        regarding "Illegal character in Path", even though I can copy, etc the
        file using the Windows XP explorer.
        >
        I can trap the error, but then this traps the entire GetFiles() function,
        not just the one bad file.
        >
        Is there a way to just trap for the one bad file and continue on?
        >
        Michael
        >

        Comment

        Working...