Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filecopy contents of folder 1

Status
Not open for further replies.

MKH2001

Technical User
Jan 7, 2003
90
GB
Heyas all,

Long time no see.
Don't know whether that is because I have been able to do the things I need to without assistance.... or whether I just haven't been all the things I need to at all and sit sharpening my pencils instead.

*cough*

Anyway Happy Xmas

And to celebrate the new year I thought I would post a request for info on something I am currently trying to do.

Basically I need to copy the WHOLE contents of a folder specified by several variables.

The results is something like:

filecopy w://development/*, w://distribution

But returns Bad file name or number error.

Have tried it with % as wildcard
filecopy w://development/%, w://distribution/<username>

But says cannot find file.

What I need is to copy all contents of folder (in this case development) to the distibution file.

All the relevant folders etc are created on the fly if they are not already present etc

Any ideas?
 
I don't think FileCopy accepts wildchards. You could probably loop the files (using Dir()), but another option might be FileSystemObject - short typed sample using late binding (no reference needed, would have been Microsoft Scripting Runtime):

[tt]dim fs as object
set fs = createobject("scripting.filesystemobject")
fs.copyfile "\\development\*.*", "\\distribution\" & <username>, true[/tt]

But shouldtn't this be in forum705 ?

Roy-Vidar
 
Worked like a charm

Current code is
Code:
Private Sub Command12_Click()
On Error GoTo Err_Command12_Click
Dim fs As Object
Set fs = CreateObject("scripting.filesystemobject")
dbName = Forms!frm_AppEntry!ApplicationFile
MyDb = Forms!frm_AppEntry!ApplicationPath
Addit = Forms!frm_AppEntry!AdditPath
LdbName = Left(dbName, Len(dbName) - 3) & "ldb"
Server = Forms!frm_AppEntry!ServerPath
vary = Forms!frm_AppEntry!Variable
If Dir(Server & LdbName) <> "" Then
MsgBox "The utility/application chosen is under development. Please wait and try again. Alternatively contact your database developer.", vbExclaimation, _
"Entry Level Application - by Mark Harris"
ElseIf Dir(MyDb & LdbName) <> "" Then
MsgBox "You are already running a previous session of this application. Attempting to unlock, if unable means you still have a live session logged in and running.You may wish to check you previous work it may be necessary to reenter your previous record details if not completed. You might also need to re-run any queries you may have been currently tunning prior to timeout.", vbExclaimation, _
"Entry Level Application - by Mark Harris"
SetAttr (MyDb & LdbName), vbNormal
Kill (MyDb & LdbName)
End If
If Len(Dir(MyDb, vbDirectory)) = 0 Then
MkDir (MyDb)
MsgBox "Creating folder", vbQuestion, _
"Entry Level Application - by Mark Harris"
End If
If Len(Dir(MyDb & AdditPath, vbDirectory)) = 0 Then
MkDir (MyDb & AdditPath)
MsgBox "Creating folder and copying database frontend", vbQuestion, _
"Entry Level Application - by Mark Harris"
End If
If vary = "" Then
MsgBox "Variable is null", vbQuestion, _
"Entry Level Application - by Mark Harris"
FileCopy Server & dbName, MyDb & Addit & dbName
ElseIf vary <> "" Then
MsgBox "Variable is not null " & Server & "to" & MyDb, vbQuestion, _
"Entry Level Application - by Mark Harris"
fs.CopyFile Server & "*.*", MyDb & Addit, True
'Sleep for 10000 milliseconds (10 Seconds)
Sleep 10000

End If
Exit_Command12_Click:
    Exit Sub

Err_Command12_Click:
    MsgBox Err.Description
    Resume Exit_Command12_Click
End Sub

Now I just need to create shell string to open a secured mdw protected db when necessary, and just open normally where not applicable.

Many thanx for prompt response....
Glad to see someone else lumbered with working on New Years Eve =)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top