Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here in the below coding i cant able to view the (.rtf) and (.doc) files
so kindly guide me with below coding


VB
Imports System.IO
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Using fold As New OpenFileDialog
            fold.Filter = "document files (*.doc)|*.doc |richtext format(*.rtf) | *.rtf |All files (*.*)|*.*"
            fold.Title = "Select file"
            If fold.ShowDialog() = Windows.Forms.DialogResult.OK Then
                ' fold.FilterIndex = 2
                fold.RestoreDirectory = True
                MessageBox.Show("You selected " & fold.FileName)
            End If
        End Using
    End Sub
End Class
Posted
Comments
LanFanNinja 11-Nov-11 0:05am    
Check my solution below.

You need to remove the spaces in your filters use this

VB
fold.Filter = "document files (*.doc)|*.doc|richtext format(*.rtf)|*.rtf|All files (*.*)|*.*"
 
Share this answer
 
You should not have any spaces between your file declarations. Try this

VB
Using fold As New OpenFileDialog
           fold.Filter = "document files (*.doc)|*.docx|richtextformat files (*.rtf)|*.rtf|All files (*.*)|*.*"
           fold.Title = "Select file"
           If fold.ShowDialog() = Windows.Forms.DialogResult.OK Then
               'fold.FilterIndex = 2
               fold.RestoreDirectory = True
               MessageBox.Show("You selected " & fold.FileName)
           End If
       End Using


Hope this helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900