Results 1 to 2 of 2

Thread: Search for a file...

  1. #1
    100 Club
    Join Date
    2008-04
    Location
    St-Ferdinand, Québec
    Posts
    124

    Default Search for a file...

    Hi Guys,

    The code below works fine, however I would like to know if there is a faster method ?

    It's not so slow but If I can do faster...

    Code:
    Dim sProjectName As String = sProjectNumber + "*.apj"
    Dim di As New IO.DirectoryInfo(sSearchPath)
    Dim diar1() As IO.FileInfo = di.GetFiles(sProjectName, IO.SearchOption.AllDirectories)
    Dim dra As IO.FileInfo
    For Each dra In diar1
        sTempFile = dra.FullName.ToString()
    Next
    As per the code above, I would like to do something like the code below, but a message appears "Variable 'dra' is used before it has been assigned a value. A null reference exception could result at runtime"

    Code:
    If dra.Length() > 0 Then
         For Each dra In diar1
              sTempFile = dra.FullName.ToString()
         Next
    End If
    Thanks in advance !

  2. #2
    100 Club
    Join Date
    2008-04
    Location
    St-Ferdinand, Québec
    Posts
    124

    Default Re: Search for a file...

    Oooopsss ! I found it !

    Code:
    If diar1.Length() > 0 Then
         For Each dra In diar1
              sTempFile = dra.FullName.ToString()
         Next
    End If
    Sorry....

Similar Threads

  1. Search file in a specific drive
    By EDDemtec in forum AutoLISP
    Replies: 15
    Last Post: 2011-09-11, 04:52 AM
  2. Print Spooler File Location or Printer Description File Search Path?
    By SweetChilly07 in forum CAD Management - General
    Replies: 4
    Last Post: 2011-04-14, 07:13 PM
  3. Options and file search paths
    By KGC in forum AutoCAD Customization
    Replies: 6
    Last Post: 2008-01-08, 03:18 PM
  4. Replies: 19
    Last Post: 2007-10-17, 03:11 PM
  5. Script file search
    By tony.upton in forum Local User Groups - General
    Replies: 2
    Last Post: 2007-08-08, 10:08 PM

Posting Permissions

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