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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Directory.GetFiles Method (String) - VB.NET 2005

Directory.GetFiles Method (String) - VB.NET 2005

Scheduled Pinned Locked Moved Visual Basic
csharpcomhelpquestion
4 Posts 2 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.
  • F Offline
    F Offline
    Freddie Code
    wrote on last edited by
    #1

    According to the Microsoft Online Help: http://msdn2.microsoft.com/en-us/library/07wt70x2.aspx For VB.NET, it says to declare GetFiles per below before using it. Why do you need to redeclare it in your code? I would thing that if it is part of the System.IO Namespace, it is already declared? Help, very confused.:confused: 'Namespace: System.IO 'Visual Basic (Declaration): Public Shared Function GetFiles(path As String) As String() 'Visual Basic (Usage): Dim path As String Dim returnValue As String() returnValue = Directory.GetFiles(path)

    D 1 Reply Last reply
    0
    • F Freddie Code

      According to the Microsoft Online Help: http://msdn2.microsoft.com/en-us/library/07wt70x2.aspx For VB.NET, it says to declare GetFiles per below before using it. Why do you need to redeclare it in your code? I would thing that if it is part of the System.IO Namespace, it is already declared? Help, very confused.:confused: 'Namespace: System.IO 'Visual Basic (Declaration): Public Shared Function GetFiles(path As String) As String() 'Visual Basic (Usage): Dim path As String Dim returnValue As String() returnValue = Directory.GetFiles(path)

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Freddie Code wrote:

      For VB.NET, it says to declare GetFiles per below before using it.

      No, it doesn't. The Declaration is only there for reference in passing parameters and what the return value, if any, is going to be. Don't include the Declaration code in your own code.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      F 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Freddie Code wrote:

        For VB.NET, it says to declare GetFiles per below before using it.

        No, it doesn't. The Declaration is only there for reference in passing parameters and what the return value, if any, is going to be. Don't include the Declaration code in your own code.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        F Offline
        F Offline
        Freddie Code
        wrote on last edited by
        #3

        I have the GetFiles method working correctlynow, thanks. GetFiles reutrns the complete path, not just the file name. Searching the help, there does not seem to be a method that just returns the file name. My goal is to prepend the file names per the users input in a textbox. What would be the best way to do this? Since the file name returned by GetFiles includes the entire path, is there an easy way to extract just the file name, modify it and resave it? Thanks.

        D 1 Reply Last reply
        0
        • F Freddie Code

          I have the GetFiles method working correctlynow, thanks. GetFiles reutrns the complete path, not just the file name. Searching the help, there does not seem to be a method that just returns the file name. My goal is to prepend the file names per the users input in a textbox. What would be the best way to do this? Since the file name returned by GetFiles includes the entire path, is there an easy way to extract just the file name, modify it and resave it? Thanks.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          There is nothing that will return just the filename. You have to parse each filepath to get the name. This is easily doen with the Path[^] class.

          Dim fn As String = Path.GetFileName(_Fully Qualified Path_)
          

          Dave Kreskowiak Microsoft MVP - Visual Basic

          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