Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 6th, 2004, 11:45 AM
Rich's Avatar
Rich Rich is offline
Administrator
Developer Shed Admin.
 
Join Date: Sep 2003
Location: Fort Lauderdale, FL
Posts: 152 Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level)Rich User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 11 h 47 m 28 sec
Reputation Power: 10
Example of the File System Object

Dim fso As New FileSystemObject
'The selected drive
Dim strDrive As String
'The folderpath
Dim strFolder As String
'Collection to store the selected filepa
' ths



Private Sub cmbDrives_Click()
Dim drive As drive
Dim File As File
Dim SubFolder As Folder
Dim i As Integer
i = 0
lstFiles.Clear
If cmbDrives = "" Then Exit Sub
strDrive = cmbDrives.Text
strFolder = ""
Set drive = fso.GetDrive(cmbDrives.Text)


If drive.IsReady Then


For Each File In drive.RootFolder.Files
lstFiles.AddItem File.Name, i
i = i + 1
Next
i = lstFiles.ListCount


For Each SubFolder In _ drive.RootFolder.SubFolders
lstFiles.AddItem SubFolder, i
i = i + 1
Next
Else
MsgBox "Drives Not ready"
End If
End Sub
'Moves to the parent folder (if any)


Private Sub cmdup_Click()
Dim Folder As Folder
Dim File As File
Dim SubFolder As Folder
Dim i As Integer
If strDrive = "" Then Exit Sub
If strFolder = "" Then Exit Sub
'Get current folder
Set Folder = fso.GetFolder(strDrive & _ strFolder)
'Find parent folder
strFolder = Left(strFolder, InStrRev _(strFolder, "\") - 1)
lstFiles.Clear
'If parent exists


If Not Folder.ParentFolder Is Nothing Then
'Add all files in parent


For Each File In Folder.ParentFolder.Files
lstFiles.AddItem File.Name, i
i = i + 1
Next
i = lstFiles.ListCount
'Add all subfolders in parent


For Each SubFolder In _ Folder.ParentFolder.SubFolders
lstFiles.AddItem SubFolder, i
i = i + 1
Next
Else 'If it Not has parent


For Each File In Folder.Files
lstFiles.AddItem File.Name, i
i = i + 1
Next
i = lstFiles.ListCount


For Each SubFolder In Folder.SubFolders
lstFiles.AddItem SubFolder, i
i = i + 1
Next
End If
End Sub


Private Sub Form_Load()
Dim drive As drive
Dim i As Integer
i = 0
'Add all drives to combo


For Each drive In fso.Drives
cmbDrives.AddItem drive.Path, i
i = i + 1
Next
End Sub


Private Sub Form_Unload(Cancel As Integer)
Set fso = Nothing
End Sub


Private Sub lstFiles_Click()
Dim Folder As Folder
Dim SubFolder As Folder
Dim File As File
Dim i As Integer
i = 0


If Not lstFiles.SelCount > 1 Then
'if its a folder


If InStr(lstFiles.Text, ":\") Then
Set Folder = fso.GetFolder _(lstFiles.Text)
lstFiles.Clear
strFolder = strFolder & "\" & _ Folder.Name
'Add all files


For Each File In Folder.Files
lstFiles.AddItem File.Name, i
i = i + 1
Next
i = lstFiles.ListCount
'Add subfolders


For Each SubFolder In _ Folder.SubFolders
lstFiles.AddItem SubFolder, i
i = i + 1
Next
End If
End If
End Sub

Reply With Quote
  #2  
Old April 22nd, 2004, 10:26 PM
cityinet cityinet is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 3 cityinet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Could you please tell me what i have to do to be able to use the filesystemobject in my project?

For instance, this code...
Code:
Dim fso As New FileSystemObject
'The selected drive
Dim strDrive As String
'The folderpath
Dim strFolder As String
'Collection to store the selected filepa
' ths


after typing New, 'FileSystemObject' is not offered like many others. Is there somehing I must do to be able to use this object?

Thanks,

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingCode Bank > Example of the File System Object


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT