[ask] created copy folder

[ask] created copy folder

Page 1 of 1

2 Replies - 1886 Views - Last Post: 09 May 2009 - 10:36 AM Rate Topic: -----

#1 ikurniawan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-May 09

[ask] created copy folder

Post icon  Posted 09 May 2009 - 07:49 AM

Hi all i'm newbie here and I want to learn VB6. I'll try to make copyfolder.. anyone can help??


thx
Is This A Good Question/Topic? 0
  • +

Replies To: [ask] created copy folder

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1638
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: [ask] created copy folder

Posted 09 May 2009 - 08:29 AM

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

#3 ikurniawan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-May 09

Re: [ask] created copy folder

Posted 09 May 2009 - 10:36 AM

View PostPsychoCoder, on 9 May, 2009 - 07:29 AM, said:

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.


here they are my script

 Dim oFSO, oSourceFolder, oTargetFolder

Private Sub Command1_Click()
  CreateFolder "e:\destination\"
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  Set oSourceFolder = oFSO.GetFolder(App.Path & "\source\") 
  Set oTargetFolder = oFSO.GetFolder("e:\destination\")

   RecursiveCopy oSourceFolder, oTargetFolder, False

End Sub
  
Private Sub RecursiveCopy(ByRef oSource, ByRef oTarget, ByVal bOverWrite)

	  Dim oFolder, oFile, szPath

	  For Each oFile In oSource.Files
		  szPath = Replace(oTarget.Path & "\" & oFile.Name, "\\", "\")
		  If Not (oFSO.FileExists(szPath) And bOverWrite) Then oFile.Copy szPath, bOverWrite
	  Next

	  For Each oFolder In oSource.Subfolders
		  szPath = Replace(oTarget.Path & "\" & oFolder.Name, "\\", "\")

		  If Not (oFSO.FolderExists(szPath) And bOverWrite) Then
			  Set oNewTarget = oFSO.CreateFolder(szPath)
		  Else
			  Set oNewTarget = oSO.GetFolder(szPath)
		  End If

		  RecursiveCopy oFolder, oTarget, bOverWrite
	  Next

  End Sub
Private Sub CreateFolder(foldername As String)
  Dim fso As New FileSystemObject
  Dim fldr As Folder
  On Error GoTo FolderError
  
  Set fldr = fso.CreateFolder(foldername)
  Set fldr = Nothing
  Set fso = Nothing
  Exit Sub
FolderError:
	 Exit Sub
  Resume Next
End Sub 



error code run-time error '76' path not found, i'll have checklist Microsoft scripting runtime.
I want to copy directory folder at e:\source\ to e:\destination\

any suggest? sorry i'm beginer

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1