Results 1 to 3 of 3

Thread: Dir function in VB.Net

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    5

    Dir function in VB.Net

    I'm writing a simple program that will periodically move all files in one folder to a different folder. When is use the Dir(pathname) function, it always seems to ignore or skip the first file in the folder. If there is only 1 file in the folder, the program thinks the folder is empty. Can anyone tell me how to fix this?
    Thanks

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Can you post your code? It kind of sounds like a zero based array issue.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    5
    It's really simple. Here it is:

    SourcePath = "c:\data1"
    TargetPath = "P:\data\NewFiles"

    ifile = Dir(SourcePath + "\*.*")
    While ifile <> ""
    ifile = Dir()

    If ifile <> "" Then
    Kill(TargetPath + "\" + ifile)
    FileCopy(SourcePath + "\" + ifile, TargetPath + "\" + ifile)
    Kill(SourcePath + "\" + ifile)
    End If
    End While

    The first call to "Dir" returns the second file in the folder, or no filename if only 1 file is in the folder.

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