473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to copy files inside subdirectories in vb6.0

Hello guys,
I'm working on a code in VB6.0 which involves copying all the files inside a folder to another folder. I have managed to do that but the problem arises when there are subfolders inside the parent folder. I cannot copy the files inside the subfolders.

For eg if my Parent Folder is C:/Anup and it contains 2 files "1.txt","2.txt" and 2 subfolders "C:/Anup/sub1 " and "C:/Anup/sub2 ", I can copy the files 1.txt,2.txt but i cannot copy the files inside sub1,sub1 along with it. Please help me on that.
Urgent help will be greatly appreciated
Mar 21 '07 #1
5 10353
I would like to add something to my query. I am working with a tool called as documentum and i need to copy all the files inside a directory (including files inside a subdirectory) into a single documentum cabinet. Hence i cannot use the copyfolder method of FileSystemObject and i have to do it file by file, directory by directory. Any help??
Mar 21 '07 #2
vijaydiwakar
579 512MB
Hi,
Try to use Shell Commands
It will defenetly help u
good luck
Mar 21 '07 #3
Hello vijay,
I have no idea what are shell commands. Could you please tell me a concise method and/or the actual code rather than just giving a vague answer?
Mar 21 '07 #4
vijaydiwakar
579 512MB
Hello vijay,
I have no idea what are shell commands. Could you please tell me a concise method and/or the actual code rather than just giving a vague answer?
try this code
Expand|Select|Wrap|Line Numbers
  1. Dim fSys As New FileSystemObject
  2.  
  3. Private Sub Form_Load()
  4. With fSys
  5. .CopyFolder "C:\temp", "D:\", True
  6. End With
  7. End Sub
  8.  
  9.  
It will copy c:\temp foleder to d:\
here temp folder contains another folder temp1
and it contains temp.txt
Good Luck
Mar 21 '07 #5
I figured it out anyways . Here is the code for other newbies(like me)

Public Function GetFolders(sStartFolderpath As String) As String
On Error Resume Next
Dim f, fldr As Folder
Set fldr = fs.GetFolder(sStartFolderpath)
GetFolders = fldr.path & vbCrLf
ReDim Preserve subfoldernames(fldr.SubFolders.Count)

If fldr.SubFolders.Count > 0 Then
For Each f In fldr.SubFolders
subfoldernames(foldercount) = f
foldercount = foldercount + 1
GetFolders = GetFolders & GetFolders(f.path)
Next
End If
End Function



THANKS AGAIN VIJAY. Thats the second time u helped me i suppose
Mar 21 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Frank | last post by:
I have files in myurl.com/myfolder and I would like to copy all of them into myurl.com/newfolder I'd like to copy all of the subdirectories and files that are in /myfolder and I would...
5
by: Anand K Rayudu | last post by:
Hi all, I am trying to find a way to get the files recursively in a given directory, The following code is failing, can some one please suggest what could be problem here from os import...
2
by: Arjen | last post by:
Hello, I want to make a command line application that search for *.htm* files inside directories and subdirectories. 1. How can I save all the *.htm* files inside directories and...
1
by: jj | last post by:
Hi folks: I can get the list of files in a certain directory by using Directory.GetFiles("c:\temp"). But I want to get the number of files (ex. 20) within a directory including all...
3
by: Steve Franks | last post by:
I think the Copy Web tool is a great idea but its implementation could use improvement. Either that or I am using it incorrectly. Basically I do not see any option to copy an entire site in one...
12
by: samoore33 | last post by:
I found a real nice article on how to copy a directory on MSDN. The only problem is that I can not figure out how to get the namespace Microsoft.VisualBasic.MyServices. I wanted to know if anyone...
1
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
Hi, I have seen many examples of moving a folder to a new location, but is there a way to simply copy it instead? For example, I want to copy the contents of folder C:\Testing\Stuff to...
2
by: manishabh77 | last post by:
can anyone suggest how I can find files in directories and subdirectories and copy them into a new directory.I tried the following code but it doesnot do the job. $inputfile1 = "file_index.txt"; ...
2
by: dj | last post by:
Hello All, I am attempting to us os.walk to populate two lists with values from a directory. The first list contains all the files in the directory and subdirectories. The second list contains...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.