Results 1 to 11 of 11

Thread: [RESOLVED] copy files need help doesnt work!!

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Resolved [RESOLVED] copy files need help doesnt work!!

    i'm trying to rename files or copy and then kill the first file my code i wrote is

    i tried

    Private Sub Command6_Click()
    Dim StrFile As String
    Dim StrFile2 As String

    Dim F1 As String
    Dim F2 As String

    F1 = Chr(34) & Text1.Text & " \ " & List3.Text & Chr(34)
    F2 = Chr(34) & Text1.Text & "\" & List2.Text & ".pacw" & Chr(34)
    StrFile = Replace(F1, Chr(34), "")
    StrFile2 = Replace(F2, Chr(34), "")
    FileCopy F1, F2
    Kill F1

    End Sub


    and then tried

    Private Sub Command6_Click()
    Dim F1 As String
    Dim F2 As String

    F1 = Chr(34) & Text1.Text & " \ " & List3.Text & Chr(34)
    F2 = Chr(34) & Text1.Text & "\" & List2.Text & ".pacw" & Chr(34)
    FileCopy F1, F2
    Kill F1

    End Sub

    for some reason it only work if i write it myself

    like

    filecopy "c:\test.txt", "c:\textreplace.txt"
    kill "c:\test.txt"


    if there is a way to just rename it be alot better but it doesnt matter either way help please, thank you!

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: copy files need help doesnt work!!

    sorry i tried this to

    Private Sub Command6_Click()
    Dim StrFile As String
    Dim StrFile2 As String

    Dim F1 As String
    Dim F2 As String

    F1 = Text1.Text & " \ " & List3.Text
    F2 = Text1.Text & "\" & List2.Text & ".pacw"

    FileCopy F1, F2
    Kill F1

    End Sub

  3. #3
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: copy files need help doesnt work!!

    there is space before and after the \
    Code:
    F1 = Text1.Text & " \ " & List3.Text
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: copy files need help doesnt work!!

    yes i noticed and fixed it still doenst work

  5. #5
    Frenzied Member
    Join Date
    Jun 2006
    Posts
    1,098

    Re: copy files need help doesnt work!!

    Code:
    Name oldpathname As newpathname

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: copy files need help doesnt work!!

    i tried this...

    FileCopy Text1.Text & "\" & List3.Text, Text1.Text & "\" & List2.Text & ".pacw"
    Kill Text1.Text & "\" & List3.Text

    it highlights FileCopy Text1.Text & "\" & List3.Text, Text1.Text & "\" & List2.Text & ".pacw"

    and in debug tells me run-time error : 52 bad file name of number
    and when i highlight Text1.Text & "\" & List3.Text and put my mouse over it it give me the right path everything is good but it doesnt work...

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: copy files need help doesnt work!!

    i tried

    Name Text1.Text & "\" & List3.Text As Text1.Text & "\" & List2.Text & ".pacw"

    run-time error 5 invalid procedure or argument

  8. #8
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: copy files need help doesnt work!!

    can u copy the file manually and directly type the path like this?
    Code:
    FileCopy "D:\test.txt", "D:\test.pacw"
    if yes then i suspect list3.text, it may not hav the extension name, and list2.text shudnt hav extension name, check these things.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: copy files need help doesnt work!!

    yes if i write it like that it works
    filecopy "c:\test.txt", "c"\test.pacw"

    ive been checking everything but like i said when im in debug mode i highlight my ff1 and ff2 and it gives me my right path which is ff1 "C:\PacWest\Max\upper1.pacw" and other one is ff2 "C:\PacWest\Max\Upper.pacw" i want to rename the upper1.pacw to upper.pacw but i dont want to put it as

    name "C:\PacWest\Max\upper1.pacw", "C:\PacWest\Max\Upper.pacw"

    I would like to name it with

    name ff1, ff2

    i use dim ff1 as string, dim ff2 as string and
    ff1 = "C:\PacWest\Max\Upper1.pacw"
    ff2 = "C:\PacWest\Max\Upper.pacw"

    Private Sub Command6_Click()
    Dim StrFile As String
    Dim StrFile2 As String

    Dim Ff1 As String
    Dim Ff2 As String

    Ff1 = "C:\PacWest\Max\Upper1.pacw"
    Ff2 = "C:\PacWest\Max\Upper.pacw"

    FileCopy Ff1, Ff2
    End Sub

    this code works

    your probably right its in my list i guess i can check in them but i'm sure it right

  10. #10
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: copy files need help doesnt work!!

    can u show me what is in textbox and listbox? dont use the " before and after the string in textbox and listbox.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: copy files need help doesnt work!!

    i found my problem it was in list2.text because when i open a file i make it write in lines

    1
    2
    3

    so i use

    MyArr = Split(Text2.Text, vbCrLf)
    For i = 0 To UBound(MyArr)

    it add a space "vbcrlf" so i removed the vbcrlf

    Private Sub Command6_Click()
    Dim StrFile2 As String
    Dim Ff1 As String
    Dim Ff2 As String

    Ff1 = "C:\PacWest\Max\Upper1.pacw" 'Text1.Text & "\" & List3.Text
    Ff2 = "C:\PacWest\Max\Upper.pacw" 'Text1.Text & "\" & List2.Text & ".pacw"
    StrFile2 = Replace(Ff2, vbCrLf, "")

    Name Ff1 As StrFile2

    End Sub

    thanks for your help guys

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