CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2007
    Posts
    30

    [RESOLVED] How to accept an input file without knowing it's name?

    I know how to use a command line parameter to allow the user to enter the name of a specific file. But what if you only know the extension, or want every file with the given extension to be processed?

    Say for example on a command line prompt the user enters the name of the exe and then *.jpg as the parameter, how can I process every file with a jpg extension? I know about regular expressions, but I don't know how to accomplish this particular problem.

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: How to accept an input file without knowing it's name?

    Code:
      Dim Files() As String = System.IO.Directory.GetFiles("C:\somedirectory", "*.jpg")
    
            For Each file As String In Files
                'do something
            Next

  3. #3
    Join Date
    Feb 2007
    Posts
    30

    Re: How to accept an input file without knowing it's name?

    Well, That sure seemed simple enough. LOL. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured