Open File

zack

Well-known member
Joined
Jun 9, 2005
Messages
65
Programming Experience
Beginner
Hi all,
how do you open a specified file without using the openfiledialog method?
 
every object that has the ability to read files accept a string that's a file path (usually the FileName property of the openfiledialog) but you can specify your own

such as:
Dim srReader As New StreamReader("c:\yourfile.txt")

instead of
Dim srReader As New StreamReader(OpenFile.FileName)
 
Hi JuggaloBrotha,

what if this file I'm trying to open is not a text file. But a file of some other type, like a shapfile(.shp). Can I stil use this method to open it too?
 
This instance only open a textfile

VB.NET:
 Dim srReader As New StreamReader("c:\test.txt") 

TextBox1.Text = srReader.ReadLine

what if i want to open a shapefile?

VB.NET:
 Dim Reader As New System.Drawing.Image("c:\25.jpeg") 

PictureBox1.Image = Reader

'New' cannot be used on a class that is declared 'MustInherit'.
How should i change it?
 
Thanks kulrom,

you are of great help!
But there seems to be a problem when the program is trying to get the image file as this error occurs: An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.drawing.dll

But I'm 100% sure that I had that file placed in that directory.
 
Back
Top