|
-
Nov 3rd, 2000, 11:09 AM
#1
I am working on a pretty small program but am having some problems making it copy th files, it always says file not found. I am pretty new to VB so I am not sure what I am doing wrong. Thanks!
Dim DirectoryPath As String, DirPath As String
DirectoryPath = "c:\saved\" & Text1.Text
DirPath = "c:\siscd\photos\*.*"
MkDir DirectoryPath
'FileCopy DirPath, DirectoryPath
FileCopy "c:\siscd\photos\*.*", DirectoryPath
-
Nov 3rd, 2000, 11:25 AM
#2
Frenzied Member
You can't just pass it *.*
You have to loop trough each file in the dir and copy it.
You know how to loop trough a dir for all files?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Nov 3rd, 2000, 11:27 AM
#3
I am not sure how to loop through each file, is that the easiest way to do something like this? Can you let me know how to do the loop? Thanks!
-
Nov 3rd, 2000, 11:43 AM
#4
Frenzied Member
kedaman wrote an excellent routine for doing this:
Code:
'CODE FROM KEDAMAN
'Toss this in a UserControl:
Option Explicit
Public BarTimer As Long
Event Filecatch(File As String, path As String, level As Integer)
Event Direcatch(dire As String, path As String, level As Integer)
Public curlevel%
Public filemax
Public Totalb$
Public diremax
Public tid
Public Directory$
Public tids As Long
Public Waiter As Long
Sub explore(startdir As String, Optional pauses = 100)
tids = Timer
filemax = 0: diremax = 0: Totalb = 0: curlevel = 0
If Right(startdir, 1) <> "\" Then startdir = startdir & "\"
ListSubDirs startdir, pauses
tid = Timer - tids
End Sub
Sub ListSubDirs(path As String, pauses)
Dim i, dmax, dirname As String, dire() As String ' Declare variables.
dirname = Dir(path, 63) ' Get first directory name.
Do While dirname <> ""
If dirname <> "." And dirname <> ".." Then
If Int(GetAttr(path + dirname) / 16) Mod 2 = 1 Then
If (dmax Mod 10) = 0 Then
ReDim Preserve dire(dmax + 10) ' Resize the array.
End If
diremax = diremax + 1: dmax = dmax + 1
dire(dmax) = dirname
RaiseEvent Direcatch(dirname, path, curlevel)
Else
filemax = filemax + 1
RaiseEvent Filecatch(dirname, path, curlevel)
End If
End If
dirname = Dir ' Get another directory name.
Waiter = Waiter + 1: If Waiter Mod (pauses) = 1 Then DoEvents
Loop
For i = 1 To dmax
curlevel = curlevel + 1
ListSubDirs path & dire(i) & "\", pauses
Next i
curlevel = curlevel - 1
End Sub
'and on the form use this:
Private Sub UserControl11_Filecatch(File As String, Path As String, level As Integer)
Debug.Print Path & File 'Print all the files to the Debug window
End If
End Sub
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
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
|