0

Hi. I was just wondering if there is a simple way to detect if the filetype is a sort of docuemnt which can be read and written. e.g. txt, docx, ini ect. I want to make it in s uch a way that when the listview selects and item it will check those filetypes and if it's not a document then a button doesn't get enabled. If it is then the button does get enabled.

Anyone?
Thnks.

2
Contributors
3
Replies
16
Views
3 Years
Discussion Span
Last Post by tinstaafl
0

You'll probably have to create a list of file extensions and use the Contains method to see if the selected file's extension is in the list.

0

You'll probably have to create a list of file extensions and use the Contains method to see if the selected file's extension is in the list.

Is there an example you could show me?

0
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim FileExtension As String = ".exe"
    If CheckExt(FileExtension) Then
        MessageBox.Show("True")
    Else
        MessageBox.Show("False")
    End If
End Sub
Dim Extensions As New List(Of String)({".txt", ".doc", ".rtf"})
Private Function CheckExt(pExtension As String) As Boolean
    Return Extensions.Contains(pExtension)
End Function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.