I use the below recursive routine to get a list of files in a directory and
it returns the extension as part of the file name in the List object even if
the "hide known file types" is checked:
Private Sub ListFiles(ByRef list As ArrayList, ByVal sPath As String,
ByVal searchpattern As String, ByVal returnpath As Boolean, ByVal chksubdir
As Boolean)
Dim di As System.IO.DirectoryInfo
Try
di = New System.IO.DirectoryInfo(sPath)
For Each fi As System.IO.FileInfo In di.GetFiles
If searchpattern = Nothing OrElse fi.Name.ToLower Like
searchpattern Then
If returnpath Then list.Add(fi.FullName) Else
list.Add(fi.Name)
End If
Next
If chksubdir Then
For Each diSub As System.IO.DirectoryInfo In di.GetDirectories
ListFiles(list, diSub.FullName, searchpattern,
returnpath, chksubdir)
Next
End If
Catch ex As Exception
list = Nothing
errmsg = ex.Message
errno = Err.Number
End Try
End Sub
"lcifers" wrote:
Is there a way, through VB.NET, to determine if the user has selected
this option? I am writing an application that does some string
functions to rename files, and the file names get chopped up if the
expected extension is not returned.
I can write another function to get around this, but if there is a
clean way to determine the state of that toggle I would rather do that.
I may need this again in the future and don't want to always write
custom string functions to get around it.
TIA.
- Luther