|
-
Nov 21st, 2003, 12:13 PM
#1
Thread Starter
New Member
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
-
Nov 21st, 2003, 12:39 PM
#2
Can you post your code? It kind of sounds like a zero based array issue.
-
Nov 21st, 2003, 12:47 PM
#3
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|