Launch a program and a function by File Type

  • Thread starter Thread starter bidalah
  • Start date Start date
B

bidalah

Hi,

I have created a program which opens up ".pcfs" files, a kind of text
file unique to my program. I want to be able to click on these files
and have the program launch AND load the contents of the clicked file.
I have been able to do the first half. I can click on a .pcfs file and
the program comes up. But how do I make the program "see" the clicked
file and load it?

I'm not even sure what this action is called, and so I haven't found
any resources on an internet search. Anybody know how to do this?

Thanks in advance.
 
bidalah said:
I have created a program which opens up ".pcfs" files, a kind of text
file unique to my program. I want to be able to click on these files
and have the program launch AND load the contents of the clicked file.
I have been able to do the first half. I can click on a .pcfs file and
the program comes up. But how do I make the program "see" the clicked
file and load it?

Add the code below to an empty ".vb" file, then select 'Sub Main' as startup
object in the project properties. 'OpenFile' can be replaced with your
logic used to open and display the file's content.

\\\
Public Module Program
Public Function Main(ByVal Args() As String) As Integer
If Args.Length > 0 Then
OpenFile(Args(0))
End If
End Function
End Module
///
 
bidalah said:
Hi,

I have created a program which opens up ".pcfs" files, a kind of text
file unique to my program. I want to be able to click on these files
and have the program launch AND load the contents of the clicked file.
I have been able to do the first half. I can click on a .pcfs file and
the program comes up. But how do I make the program "see" the clicked
file and load it?

I'm not even sure what this action is called, and so I haven't found
any resources on an internet search. Anybody know how to do this?

Thanks in advance.

You need to look at the command line arguments when your program
launches. The filename and path will be passed in that way. So you
just have a function to open the file when it sees a file. Do a search
on "vb.net commandline arguments" and you'll get a lot of examples.
 

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

Back
Top