Results 1 to 8 of 8

Thread: [RESOLVED] Copy mp3 file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    Resolved [RESOLVED] Copy mp3 file

    Hi
    On my form I have the following:-
    3 Textboxes Text1,txtCount and fleType
    DriveListBox - Drive1
    DirListBox - Dir1
    FileListBox - File1
    Command Button - cmdCopy

    The files load OK but I get error 53 when I try to copy the mp3 file from the
    FileListBox.

    Code

    Option Explicit
    'Strings
    Private myPathChanged As String
    Public myFile As String
    Private strFullPath As String

    Private Sub cmdCopy_Click()
    ChDrive ("C")
    ChDir "\Test\"
    MsgBox "The current directory is " & CurDir
    Do Until txtCount = 0
    FileCopy myFile, "C:\Test"
    Loop
    End Sub

    Private Sub dir1_Change()
    Dim xNum As Integer

    File1.Path = Dir1.Path
    If frmFront.Visible = True Then
    File1.Pattern = fleType
    If Dir1.Path <> Text1.Text Then
    xNum = Len(Text1.Text) + 5
    myPathChanged = Mid$(Dir1.Path, xNum)

    If Drive1 = "c:" Then
    Text1.Text = Mid(Dir1.Path, 4) 'Display path in Textbox
    Else
    Text1 = Left$(Dir1.Path, 2) 'Display Drive in Textbox
    End If
    End If
    End If

    If File1.ListCount > 0 Then
    txtCount = File1.ListCount '- 1
    txtCount.ForeColor = &H0&
    End If

    End Sub

    Private Sub Drive1_Change()
    On Error Resume Next
    Dir1.Path = Drive1.Drive
    Drive1.Drive = Left$(Dir1.Path, 2)
    End Sub

    Private Sub File1_Click()

    strFullPath = Dir1.Path

    If Right$(Dir1.Path, 1) <> "\" Then strFullPath = strFullPath & "\"

    strFullPath = strFullPath & File1.FileName
    myFile = File1.FileName
    cmdCopy.Enabled = True

    ' MsgBox strFullPath, , "Full Path"
    End Sub

    Private Sub Form_Load()
    fleType.Text = "*.mp3"
    If Dir1.Path <> "G:\My Music\" Then Dir1.Path = "G:\My Music\"
    File1.Path = Dir1.Path
    Text1.Text = File1.Path
    Drive1.Drive = Left$(Dir1.Path, 2)
    Dir1.Path = Text1.Text
    End Sub

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Copy mp3 file

    When you copy a file, ensure both the source & destination include the file name. Appears your destination is just a folder
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    Re: Copy mp3 file

    Hi LaVolpe

    Thanks for your prompt reply I changed the code and I think that error is
    solved. I am getting Error 70 Permission Denied so I included some more
    code but that did not resolve error 70 can you help again please.

    Code:-
    Private Sub cmdCopy_Click()
    Dim fs As New FileSystemObject
    Dim Orig_Path As String, New_Path As String
    Dim xFolder As Folder
    Dim xFile As File

    Orig_Path = myFile
    New_Path = "C:\Test"
    Set xFolder = fs.GetFolder(New_Path)
    For Each xFile In xFolder.Files
    xFile.Attributes = Normal
    Next

    Do Until txtCount = 0
    fs.CopyFile Orig_Path, New_Path, True
    txtCount = txtCount - 1
    Loop

    End Sub

  4. #4
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: Copy mp3 file

    Be sure to use [highlight=vb][/highlight] when posting vb code on the forums

  5. #5
    Lively Member bren0098's Avatar
    Join Date
    Jul 2005
    Posts
    67

    Re: Copy mp3 file

    Permission denied means you don't have access to that folder. Try copying a file from Windows explorer to that folder. If you get a similar error then you don't have permission to copy that file to the selected folder. If you don't get an error then it's a whole other ball of wax.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    Re: Copy mp3 file

    Hi
    I have no problems when I copy the same file with Windows.

    I was thinking last night that the folder I had given the normal permission to was
    the wrong one so I changed that line in my code and I am now back to error 76
    Path Not Found I am not sure why can anybody help.

    Changed:- Set xFolder = fs.GetFolder(New_Path) to Set xFolder = fs.GetFolder(Orig_Path)

  7. #7
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Copy mp3 file

    Why not use one of the methods in this thread?
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2010
    Posts
    445

    Re: Copy mp3 file

    Hi
    Thanks to all for your help and especially to Nightwalker83 the link to the thread you gave me works fine.
    Regards

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