CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Help, please...

  1. #1
    Join Date
    Oct 1999
    Posts
    15

    Help, please...

    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






  2. #2
    Join Date
    Sep 1999
    Location
    Germany
    Posts
    66

    Re: Help, please...

    Test it:

    Private Sub Form_Load()

    Dim FileSource$
    Dim FileDestination$

    On Error Resume Next

    FileDay = Format(Now, "dd")

    MsgBox (FileDay)
    MsgBox (DirExists("C:\" & FileDay))

    If DirExists("C:\" & FileDay) = False Then MkDir ("C:\" & FileDay)

    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

    File2.Path = "c:\Program Files\DEPCON\print\"

    For x = 0 To (File2.ListCount - 1)
    MsgBox (File2.ListCount - 1)
    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

    If SkipThis = True And Err = 53 Then
    MkDir ("C:\" & FileDay)
    Else
    MsgBox ("error!!!!! error!!!!!")
    End If

    End Sub

    [email protected]
    http://smalig.tripod.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured