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.

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.

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?

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.