Hi All I do not read file content except .txt file .Can you give universal solution in vb dotnet to read content all type of file. Thanks in advance

            Dim filetoread As String = "c:\CodeNotes_NET.pdf"
            Dim filestream As StreamReader
            filestream = File.OpenText(filetoread)
            Dim readcontents As String
            readcontents = filestream.ReadToEnd()

There is no universal solution for reading all types of files.
Just like on your computer, each file type requires a different "handler".
For instance, you don't use MS Word to load, read and edit a PDF file.

So, for a PDF, you will need to use COM automation or an Acrobat dot net DLL that will allow you to open, read and print.

With that said, you CAN read files as just a group of BYTES, but I assume you didn't mean that.

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.