|
-
Nov 21st, 2011, 09:56 AM
#1
Thread Starter
Hyperactive Member
[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
-
Nov 21st, 2011, 10:06 AM
#2
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
-
Nov 21st, 2011, 11:17 AM
#3
Thread Starter
Hyperactive Member
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
-
Nov 21st, 2011, 01:45 PM
#4
Re: Copy mp3 file
Be sure to use [highlight=vb][/highlight] when posting vb code on the forums
-
Nov 21st, 2011, 02:44 PM
#5
Lively Member
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.
-
Nov 22nd, 2011, 03:32 AM
#6
Thread Starter
Hyperactive Member
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)
-
Nov 22nd, 2011, 03:53 AM
#7
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
-
Nov 22nd, 2011, 04:44 AM
#8
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|