|
-
May 11th, 2007, 08:02 PM
#1
Thread Starter
New Member
Copy To all folder and Sub Folder
Please Help me
Any one know how can i copy a file to Root folder and all sub folder of Root folder
only with one click of button
-
May 11th, 2007, 08:21 PM
#2
Re: Copy To all folder and Sub Folder
vb Code:
Option Explicit
Private Sub command1_Click()
Dim sFolder() As String
Dim sTmpFolder As String
Dim sFile As String
Dim sPath As String
Dim i As Integer
sPath = "C:\WINDOWS\Desktop\Test"
sTmpFolder = Dir(sPath, vbDirectory)
Do While sTmpFolder <> ""
If sTmpFolder <> "." And sTmpFolder <> ".." Then
If (GetAttr(sPath & sTmpFolder) And vbDirectory) = vbDirectory Then
ReDim Preserve sFolder(0 To i)
sFolder(i) = sTmpFolder & "\"
i = i + 1
End If
End If
sTmpFolder = Dir
Loop
Do Until Dir(sPath) = ""
sFile = Dir(sPath)
Kill sPath & sFile
Loop
For i = 0 To UBound(sFolder)
sTmpFolder = sPath & sFolder(i)
Do Until Dir(sTmpFolder) = ""
sFile = Dir(sTmpFolder)
Kill sTmpFolder & sFile
Loop
Next
Exit Sub
End Sub
This is a function that will delete all the files in all the sub folder and root folder. I know it ain't what your searching for but it might give you an idea of what you are looking at here Sorry i couldn't be of more help i got to be somewhere cya.
-
May 11th, 2007, 08:35 PM
#3
Re: Copy To all folder and Sub Folder
Might be overkill for what you're doing, but the folder operations in the class from my signature handle subfolders during copy/move/delete operations.
-
May 11th, 2007, 08:45 PM
#4
Thread Starter
New Member
Re: Copy To all folder and Sub Folder
ok thanks
it is not possible
-
May 12th, 2007, 07:51 AM
#5
Re: Copy To all folder and Sub Folder
How about the filesystem object
Code:
Private Sub Command1_Click()
Dim fso As FileSystemObject
Set fso = New FileSystemObject
fso.CopyFolder "C:\images", "c:\temp\images"
Set fso = Nothing
End Sub
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
|