Xemion
October 17th, 1999, 09:38 PM
Can somebody please tell my why this code is not copying the file? Am I doing something wrong? As you can see, I've tried several different copy methods! Please help! Thanks!
Xemion
private Sub Form_Load()
on error GoTo WeHaveError
FileDay = Format(Now, "dd")
MsgBox (FileDay)
MsgBox (DirExists("C:\" & FileDay))
If DirExists("C:\" & FileDay) = false then
MkDir ("C:\" & FileDay)
End If
on error GoTo WeHaveABigError
File1.Path = "C:\" & FileDay
MsgBox (File1.Path)
for x = 0 to (File1.ListCount - 1)
If Left(FileDateTime(File1.Path & "\" & File1.List(x)), 10) <> Format(Now, "mm/dd/yyyy") then
MsgBox ("Deleting..." & File1.Path & "\" & File1.List(x))
Kill (File1.Path & "\" & File1.List(x))
End If
next x
File2.Path = "c:\Program Files\DEPCON\print\"
for x = 0 to (File2.ListCount - 1)
MsgBox (File2.ListCount - 1)
'set CopyThisFile = fso.GetFile(File2.Path & "\" & File2.List(x))
'FileSystemObject.CopyFile (File2.Path & "\" & File2.List(x)), (File1.Path & "\")
'CopyThisFile.Copy (File1.Path & "\" & File2.List(x))
Dim FileSource, FileDestination
FileSource = File2.Path & "\" & File2.List(x)
FileDestination = File1.Path & "\"
File1.Path = FileDestination
MsgBox ("File to Be Copied " & FileSource)
MsgBox ("Folder to Be Copied to " & FileDestination)
FileCopy FileSource, FileDestination
next x
If SkipThis = true then
WeHaveError:
If Err = 53 then
MkDir ("C:\" & FileDay)
else
MsgBox ("error!!!!! error!!!!!")
End If
resume next
WeHaveABigError:
End If
End Sub
public Function DirExists(byval strDirName as string) as Integer
Dim strDummy as string
on error resume next
If Right$(strDirName, 1) <> "\" then
strDirName = strDirName & "\"
End If
strDummy = Dir$(strDirName & "*.*", vbDirectory)
DirExists = Not (strDummy = vbNullString)
Err = 0
End Function
Xemion
private Sub Form_Load()
on error GoTo WeHaveError
FileDay = Format(Now, "dd")
MsgBox (FileDay)
MsgBox (DirExists("C:\" & FileDay))
If DirExists("C:\" & FileDay) = false then
MkDir ("C:\" & FileDay)
End If
on error GoTo WeHaveABigError
File1.Path = "C:\" & FileDay
MsgBox (File1.Path)
for x = 0 to (File1.ListCount - 1)
If Left(FileDateTime(File1.Path & "\" & File1.List(x)), 10) <> Format(Now, "mm/dd/yyyy") then
MsgBox ("Deleting..." & File1.Path & "\" & File1.List(x))
Kill (File1.Path & "\" & File1.List(x))
End If
next x
File2.Path = "c:\Program Files\DEPCON\print\"
for x = 0 to (File2.ListCount - 1)
MsgBox (File2.ListCount - 1)
'set CopyThisFile = fso.GetFile(File2.Path & "\" & File2.List(x))
'FileSystemObject.CopyFile (File2.Path & "\" & File2.List(x)), (File1.Path & "\")
'CopyThisFile.Copy (File1.Path & "\" & File2.List(x))
Dim FileSource, FileDestination
FileSource = File2.Path & "\" & File2.List(x)
FileDestination = File1.Path & "\"
File1.Path = FileDestination
MsgBox ("File to Be Copied " & FileSource)
MsgBox ("Folder to Be Copied to " & FileDestination)
FileCopy FileSource, FileDestination
next x
If SkipThis = true then
WeHaveError:
If Err = 53 then
MkDir ("C:\" & FileDay)
else
MsgBox ("error!!!!! error!!!!!")
End If
resume next
WeHaveABigError:
End If
End Sub
public Function DirExists(byval strDirName as string) as Integer
Dim strDummy as string
on error resume next
If Right$(strDirName, 1) <> "\" then
strDirName = strDirName & "\"
End If
strDummy = Dir$(strDirName & "*.*", vbDirectory)
DirExists = Not (strDummy = vbNullString)
Err = 0
End Function