Text file in project

D

d4

I added a Text file to my Project (Add > New Item > Text File).
I've added a button so when a user clicks on it it will bring up the
text file to read, only problem is I cannot figure out how to call the
Text file to show? I'm sure its easy, but I don't see it. Thanks in
advance.
 
G

Guest

you can either make a form thatl display it to the user, or you can use

System.Diagnostics.Process.Start(''Text File Location Here'')

which will bring up the system's default text editing program with the file
loaded (ex notepad)

hope this helps!
 
E

eBob.com

In addition to iwds15's suggestion you could put a RichTextBox on your form
and assign the file text to its .Text member.

Bob
 
M

Miro

Here is a sub question for everyone, after reading this I tried
something and I couldn't quite figure it out.
I cant quite seem to google it either as the words im searching for are
too vague for htm and webbrowser.

I added a simple .htm file to my app and added to a form a webbrowser
control. However I cant seem to figure out how to load that htm file in
the browser control.
( trying to open it within my form ) instead of opening up a new process.

Miro
 
G

Guest

just use

Me.WebBrowser1.Navigate("Full Path to HTML File Here")

and thatl browse the IE control to that file

hope this helps!
 
G

Guest

d4 said:
I added a Text file to my Project (Add > New Item > Text File).
I've added a button so when a user clicks on it it will bring up the
text file to read, only problem is I cannot figure out how to call the
Text file to show? I'm sure its easy, but I don't see it. Thanks in
advance.
Every file (wav, jpg, txt, ico, etc.) that you add to your project is called
a resource. To access a resource, you can use code like this:

'Textfiles are treated as strings !
Dim myString As String
myString = My.Resources.TextFile_1
TextBox1.Text = myString

If you want know more about resources, please have a look at the
my.resources namespace or search MSDN for something like "Basic concepts of
resources" or "Working with resources".
 
D

d4

I should have mentioned that this is a Windows App
The Process.Start has the "The system cannot find the file specified"
exception, and I couldn't find it in My.Resources,
so I just created a RichTextBox on a form and put the text in there.
Not exactly what I wanted, but it'll do.
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top