|
|
![]() |
|
|
Top | #1 |
|
Unregistered
Posts: n/a
|
How would I go about this? Say if I wanted to back up winini.bat to a floppy drive or something like that? Anyhelp greatly appreciated |
|
|
|
Top | #2 |
|
...will circle this city
Joined: April 2002
Location: Calgary, Alberta
Posts: 528
Reputation: 0
Power: 128 |
are you saying search and entire HD for it? because that would take some coding, big time. or do you just mean supplying a directory (without sub-dirs) and checking if it is there?
|
|
|
|
|
|
Top | #3 |
|
Unregistered
Posts: n/a
|
Specifying the directory and then sub dir's off that...
|
|
|
|
Top | #4 |
|
...will circle this city
Joined: April 2002
Location: Calgary, Alberta
Posts: 528
Reputation: 0
Power: 128 |
hmm i think that i could get it to search in the dir, but not the sub dir. that's a maybe though. haven't done any major vb in like 2 yrs
|
|
|
|
|
|
Top | #5 |
|
Unregistered
Posts: n/a
|
The answer you seek is simple.
Click project -> referneces -> then add in Microsoft Scripting Runtime. File name scrrun.dll Next add some code dim fso as FileSystem Object Set fso = New FileSystemObject if fso.FileExists(QualifiedSrcFileAndPath) = true then fso.CopyFile QualifiedSrcFileAndPath, QualifiedDestFileAndPath, True end if 'The True is to force an overwrite if the file already exists in the destination directory. Set fso = Nothing |
|
|
|
Top | #6 |
|
OSNN Veteran Addict
Joined: May 2002
Location: London England
Posts: 1,014
Reputation: 140
Power: 133 |
There are so many ways to do this it might be best if you stated what the operating system/s you wanted to achieve this under was: as you could use: -
Scripting, API calls, VB functions and a host of other methods or add-ins including batch file processing. |
|
|
|
|
|
Top | #7 |
|
Unregistered
Posts: n/a
|
Here's code that will recusively search a directory...
Code:
Sub RecursiveSearch(ByVal sPattern As String, ByVal CurrDir As String, sFound() As String)
Dim i As Integer
Dim sCurrPath As String
Dim sFile As String
Dim ii As Integer
Dim iFiles As Integer
Dim iLen As Integer
If Right$(CurrDir, 1) <> "\" Then
Dir1.Path = CurrDir & "\"
Else
Dir1.Path = CurrDir
End If
'keep on going into the directories until there are no more left
For i = 0 To Dir1.ListCount
If Dir1.List(i) <> "" Then
DoEvents 'make sure it doesn't crash
Call RecursiveSearch(sPattern, Dir1.List(i), sFound)
Else
If Right$(Dir1.Path, 1) = "\" Then
sCurrPath = Left(Dir1.Path, Len(Dir1.Path) - 1)
Else
sCurrPath = Dir1.Path
End If
'copy path to string
File1.Path = sCurrPath
'copy pattern data to string
File1.Pattern = sPattern
If File1.ListCount > 0 Then 'matching files found in the directory
For ii = 0 To File1.ListCount - 1
'resize array for a new file
ReDim Preserve sFound(UBound(sFound) + 1)
sFound(UBound(sFound) - 1) = File1.List(ii)
Next ii
End If
iLen = Len(Dir1.Path)
Do While Mid(Dir1.Path, iLen, 1) <> "\"
iLen = iLen - 1
Loop
Dir1.Path = Mid(Dir1.Path, 1, iLen)
End If
Next i
End Sub
Call RecursiveSearch("file.ext", "C:/", fileArray()) That will search for file named "file.ext", in the Entire C:/ drive, and output all matches into an array called fileArray() |
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| HL2 Stuff | Teddy | PC Gaming | 1 | October 1st, 2004 2:28am |
| what does this stuff mean? | canadian_divx | Windows Desktop Systems | 4 | May 22nd, 2003 7:56am |
| New Stuff | Electronic Punk | Site Problems & Feedback | 11 | September 7th, 2002 7:40pm |