how to get windows to open text with my app

Hi,how do i get windows to open txt files with my program i made with vb2005
[77 byte] By [james_m] at [2007-12-20]
# 1

I think you're asking, "When I double-click on a .txt file in Windows, how do I get Windows to open the .txt file with my VB application?" If that's the case, the easiest thing to do is to open Windows Explorer, find a text file (extension is .txt), right click on the file, select "Open with..." then select choose program. You can then browse to your .exe and select "Always use the selected program to open this kind of file."

If what you're asking is "how do I open a .txt file with VB 2005" there are a few scenarios there -- the easiest is probably writing code to associate a RichTextBox control with a filestream like this:

Dim MyFileStream As New FileStream(FilePath, FileMode.Open)
RichTextBox1.LoadFile(MyFileStream, _
RichTextBoxStreamType.PlainText)
MyFileStream.Close()

There are some really good full samples/examples at http://www.windowsforms.net/Default.aspx?tabindex=4&tabid=49 written by the Windows Forms team if that's what you're after.

John

johnmont at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2
sir,did what you said but it opens my program and the textbox is blank
james_m at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

Assuming that you have the logic for loading text into your textbox already, I'm going to guess that the next thing you need to do is to alter your program so that when it initializes, it checks for command line parameters (like a filename) and pushes those into your loadfile method. (I'd also recommend switching from textBox to richTextBox.)

-John

johnmont at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4

from textBox to richTextBox did the trick !

thank you so much for the help

jim

james_m at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 5
No problem -- mark it as answered. ;-)
johnmont at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...