|
-
Mar 27th, 2007, 04:13 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [02/03] Multiple File Extensions
Hello all!
I've a program in which I list all the directories, Then, all the files within those directories. I have a list view, and I must load files with multiple file extensions into it. Let me explain better:
Say for example I want to list files with either a .dot or a .doc extension into the listview.
This loads the dirs & the Files :
Code:
Private Sub SSLoadDir(ByVal SSDirList As String)
Try
For Each SSFolderList As String In Directory.GetDirectories(SSDirList)
Dim SubFolderList As String = lstSSDir.Items.Add(SSFolderList)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub SSLoadFile()
Dim SSFolder As String = CStr(SSDir)
If Not SSFolder Is Nothing AndAlso IO.Directory.Exists(SSFolder) Then
For Each SSFile As String In IO.Directory.GetFiles(SSFolder)
Dim SSTempExt As String = IO.Path.GetExtension(SSFile)
Dim SSDateMod As String = IO.File.GetLastWriteTime(SSFile).ToString()
Dim SSDateCreate As String = IO.File.GetCreationTime(SSFile).ToString()
If SSTempExt = SSFilExt Then 'THIS Fails
Dim SSItem1 As New ListViewItem(SSFile.ToString())
SSItem1.SubItems.Add(SSDateCreate.ToString())
SSItem1.SubItems.Add(SSDateMod.ToString())
lvSSFiles.Items.AddRange(New ListViewItem() {SSItem1}) 'add everything
End If
Next
End If
End Sub
I tried makig a String variable that looks like :
Code:
FilExt = "*.doc;*.dot"
Once the files are loaded into the listview, I'll need to open the associated program.
I just want to know if I can set up a "filter" and load ONLY those files within the filter, into the listview?
-
Mar 27th, 2007, 07:14 AM
#2
Re: [02/03] Multiple File Extensions
Directory.GetFiles has an overload where you can specify a filter.
It looks something like this if you just want the .doc files from the SSfolder directory
Code:
For Each SSFile As String In IO.Directory.GetFiles(SSFolder, "*.doc")
Next
-
Mar 27th, 2007, 07:49 AM
#3
Thread Starter
Hyperactive Member
Re: [02/03] Multiple File Extensions
Thanx, I think that's what I need
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
|