PC Review


Reply
Thread Tools Rate Thread

How do I launch vb app with a file drag over

 
 
Paul
Guest
Posts: n/a
 
      9th Dec 2003
I have looked and looked for this info. All the I/O
examples I've found either explicity use a file name or use
the OpenFileDialog. When you drag a MS Word document over
MS Word, it launches and opens the document. I would like
my App to launch and open a document (if it has the correct
extension). What is the launch event sequence and where do
I pick up the path/name of the file or files that were
dropped on the application icon?

Any advice or link to info about this is appreciated.

Thanks.

Paul
 
Reply With Quote
 
 
 
 
Brian W
Guest
Posts: n/a
 
      9th Dec 2003
IIRC, when you drop a file on an icon windows will start the application
passing the path to the dropped file as a parameter.


HTH
Brian W



"Paul" <(E-Mail Removed)> wrote in message
news:036101c3be85$099a2290$(E-Mail Removed)...
> I have looked and looked for this info. All the I/O
> examples I've found either explicity use a file name or use
> the OpenFileDialog. When you drag a MS Word document over
> MS Word, it launches and opens the document. I would like
> my App to launch and open a document (if it has the correct
> extension). What is the launch event sequence and where do
> I pick up the path/name of the file or files that were
> dropped on the application icon?
>
> Any advice or link to info about this is appreciated.
>
> Thanks.
>
> Paul



 
Reply With Quote
 
Guest
Posts: n/a
 
      9th Dec 2003
Yes, I figured it would launch the program and execute the
code I have in Sub Main. The question is, what parameter
contains the path/name of the file? I'm assuming it would
/could be an array of path names because a person can
select several files and drop them on at once - or
possibly a folder of files.

In this specific case, I don't even need to open a form -
Just read the dropped file, reformat the data a bit and
write it back out to the same location (path) with the same
name and a different extension. If mulitple files are
dropped I could create an output file for each or combine
the data in all of them to one output file.

So - what parameter do I look at?
Thanks,

Paul
>-----Original Message-----
>IIRC, when you drop a file on an icon windows will start

the application
>passing the path to the dropped file as a parameter.
>
>
>HTH
>Brian W
>
>
>
>"Paul" <(E-Mail Removed)> wrote in message
>news:036101c3be85$099a2290$(E-Mail Removed)...
>> I have looked and looked for this info. All the I/O
>> examples I've found either explicity use a file name or use
>> the OpenFileDialog. When you drag a MS Word document over
>> MS Word, it launches and opens the document. I would like
>> my App to launch and open a document (if it has the correct
>> extension). What is the launch event sequence and where do
>> I pick up the path/name of the file or files that were
>> dropped on the application icon?
>>
>> Any advice or link to info about this is appreciated.
>>
>> Thanks.
>>
>> Paul

>
>
>.
>

 
Reply With Quote
 
Brian W
Guest
Posts: n/a
 
      10th Dec 2003
What do you mean what parameter?

It's not really that difficult, take a look at command$

try the following code:

Sub Main()
Dim s As String = Command$()
Console.WriteLine(s)
Console.ReadLine()
End Sub

Drop 1 to N files on the compiled .EXE, you will find something like this:

The file names will be quoted and space delimited.


Regards
Brian W


<(E-Mail Removed)> wrote in message
news:019a01c3be94$05ba0460$(E-Mail Removed)...
> Yes, I figured it would launch the program and execute the
> code I have in Sub Main. The question is, what parameter
> contains the path/name of the file? I'm assuming it would
> /could be an array of path names because a person can
> select several files and drop them on at once - or
> possibly a folder of files.
>
> In this specific case, I don't even need to open a form -
> Just read the dropped file, reformat the data a bit and
> write it back out to the same location (path) with the same
> name and a different extension. If mulitple files are
> dropped I could create an output file for each or combine
> the data in all of them to one output file.
>
> So - what parameter do I look at?
> Thanks,
>
> Paul
> >-----Original Message-----
> >IIRC, when you drop a file on an icon windows will start

> the application
> >passing the path to the dropped file as a parameter.
> >
> >
> >HTH
> >Brian W
> >
> >
> >
> >"Paul" <(E-Mail Removed)> wrote in message
> >news:036101c3be85$099a2290$(E-Mail Removed)...
> >> I have looked and looked for this info. All the I/O
> >> examples I've found either explicity use a file name or use
> >> the OpenFileDialog. When you drag a MS Word document over
> >> MS Word, it launches and opens the document. I would like
> >> my App to launch and open a document (if it has the correct
> >> extension). What is the launch event sequence and where do
> >> I pick up the path/name of the file or files that were
> >> dropped on the application icon?
> >>
> >> Any advice or link to info about this is appreciated.
> >>
> >> Thanks.
> >>
> >> Paul

> >
> >
> >.
> >



 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      10th Dec 2003
Brian,
Thank you for your example. You previously posted the file
names would be passed as a parameter (...when you drop a
file on an icon windows will start the application passing
the path to the dropped file as a parameter.) so I was
asking what parameter that would be. It looks like the
dropped path/file names are put into s by the Dim s As
String = Command$() line. So I'll research Command$().
Thanks for pointing me in the right direction.
Paul

>-----Original Message-----
>What do you mean what parameter?
>
>It's not really that difficult, take a look at command$
>
>try the following code:
>
> Sub Main()
> Dim s As String = Command$()
> Console.WriteLine(s)
> Console.ReadLine()
> End Sub
>
>Drop 1 to N files on the compiled .EXE, you will find

something like this:
>
>The file names will be quoted and space delimited.
>
>
>Regards
>Brian W
>
>
><(E-Mail Removed)> wrote in message
>news:019a01c3be94$05ba0460$(E-Mail Removed)...
>> Yes, I figured it would launch the program and execute the
>> code I have in Sub Main. The question is, what parameter
>> contains the path/name of the file? I'm assuming it would
>> /could be an array of path names because a person can
>> select several files and drop them on at once - or
>> possibly a folder of files.
>>
>> In this specific case, I don't even need to open a form -
>> Just read the dropped file, reformat the data a bit and
>> write it back out to the same location (path) with the same
>> name and a different extension. If mulitple files are
>> dropped I could create an output file for each or combine
>> the data in all of them to one output file.
>>
>> So - what parameter do I look at?
>> Thanks,
>>
>> Paul
>> >-----Original Message-----
>> >IIRC, when you drop a file on an icon windows will start

>> the application
>> >passing the path to the dropped file as a parameter.
>> >
>> >
>> >HTH
>> >Brian W
>> >
>> >
>> >
>> >"Paul" <(E-Mail Removed)> wrote in

message
>> >news:036101c3be85$099a2290$(E-Mail Removed)...
>> >> I have looked and looked for this info. All the I/O
>> >> examples I've found either explicity use a file name

or use
>> >> the OpenFileDialog. When you drag a MS Word document over
>> >> MS Word, it launches and opens the document. I would like
>> >> my App to launch and open a document (if it has the

correct
>> >> extension). What is the launch event sequence and

where do
>> >> I pick up the path/name of the file or files that were
>> >> dropped on the application icon?
>> >>
>> >> Any advice or link to info about this is appreciated.
>> >>
>> >> Thanks.
>> >>
>> >> Paul
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Chris Dunaway
Guest
Posts: n/a
 
      10th Dec 2003
On Wed, 10 Dec 2003 03:07:48 -0800, Paul wrote:

> Brian,
> Thank you for your example. You previously posted the file
> names would be passed as a parameter (...when you drop a
> file on an icon windows will start the application passing
> the path to the dropped file as a parameter.) so I was
> asking what parameter that would be. It looks like the
> dropped path/file names are put into s by the Dim s As
> String = Command$() line. So I'll research Command$().
> Thanks for pointing me in the right direction.
> Paul
>
>>-----Original Message-----
>>What do you mean what parameter?
>>
>>It's not really that difficult, take a look at command$
>>
>>try the following code:
>>
>> Sub Main()
>> Dim s As String = Command$()
>> Console.WriteLine(s)
>> Console.ReadLine()
>> End Sub
>>
>>Drop 1 to N files on the compiled .EXE, you will find

> something like this:
>>
>>The file names will be quoted and space delimited.
>>
>>
>>Regards
>>Brian W
>>
>>
>><(E-Mail Removed)> wrote in message
>>news:019a01c3be94$05ba0460$(E-Mail Removed)...
>>> Yes, I figured it would launch the program and execute the
>>> code I have in Sub Main. The question is, what parameter
>>> contains the path/name of the file? I'm assuming it would
>>> /could be an array of path names because a person can
>>> select several files and drop them on at once - or
>>> possibly a folder of files.
>>>
>>> In this specific case, I don't even need to open a form -
>>> Just read the dropped file, reformat the data a bit and
>>> write it back out to the same location (path) with the same
>>> name and a different extension. If mulitple files are
>>> dropped I could create an output file for each or combine
>>> the data in all of them to one output file.
>>>
>>> So - what parameter do I look at?
>>> Thanks,
>>>
>>> Paul
>>> >-----Original Message-----
>>> >IIRC, when you drop a file on an icon windows will start
>>> the application
>>> >passing the path to the dropped file as a parameter.
>>> >
>>> >
>>> >HTH
>>> >Brian W
>>> >
>>> >
>>> >
>>> >"Paul" <(E-Mail Removed)> wrote in

> message
>>> >news:036101c3be85$099a2290$(E-Mail Removed)...
>>> >> I have looked and looked for this info. All the I/O
>>> >> examples I've found either explicity use a file name

> or use
>>> >> the OpenFileDialog. When you drag a MS Word document over
>>> >> MS Word, it launches and opens the document. I would like
>>> >> my App to launch and open a document (if it has the

> correct
>>> >> extension). What is the launch event sequence and

> where do
>>> >> I pick up the path/name of the file or files that were
>>> >> dropped on the application icon?
>>> >>
>>> >> Any advice or link to info about this is appreciated.
>>> >>
>>> >> Thanks.
>>> >>
>>> >> Paul
>>> >
>>> >
>>> >.
>>> >

>>
>>
>>.
>>


You can also declare you sub main thusly:

Sub Main(sArgs() As String)

End Sub


The the sArgs array would contain all the command line parameters.

Also look as Environment.CommandLine

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      10th Dec 2003
snip

You can also declare you sub main thusly:

Sub Main(sArgs() As String)

End Sub

Chris,

Are you saying that in that syntax, sArgs() will already
contain the string for file name/s or will I still need to
put them in there via sArgs = Command$()

I'm sorry to be such a newbie at this - I've worked with
VB6 and other Basics before but I seem to be having a hard
time finding the info I need for vb.net.

It looks like you no longer compile to an .exe. Instead you
do a Build, then run an Install/Deploy wizard to combine
all the parts to an .exe

That makes testing this situation a little ackward as I
can't drop a file on till I get to that .exe

Paul

 
Reply With Quote
 
Brian W
Guest
Posts: n/a
 
      11th Dec 2003
No, you do not assign sArgs=Command$()

Each element in the sArgs array will be a parameter.

In other words, assume you drop the following files onto your EXE:

file1.txt file2.txt file3.txt

you can then loop through the array like this

Dim s As String
for each s in sArgs
DoSomething(s) ' Do something with the file.
next

This is actually easier than VB 6 or below, there it was up to you to parse
the command line, here most of the work is done for you.


> I'm sorry to be such a newbie at this - I've worked with
> VB6 and other Basics before but I seem to be having a hard
> time finding the info I need for vb.net.


There is plenty of info out there, just pick a topic and Google it.

> It looks like you no longer compile to an .exe. Instead you
> do a Build, then run an Install/Deploy wizard to combine
> all the parts to an .exe


Where did you get that idea? And is simple untrue. Your compiled application
will be in the Bin directory under your solution directory.

If your solution contains other projects referenced by your main EXE project
(Class libraries, Control libraries etc) they will be in the Bin directory
as well.



Regards
Brian W





>
> That makes testing this situation a little ackward as I
> can't drop a file on till I get to that .exe
>
> Paul
>



 
Reply With Quote
 
Guest
Posts: n/a
 
      12th Dec 2003
Brian,
I completely understand. Just what I was looking for. Thanks.
Paul

>-----Original Message-----
>No, you do not assign sArgs=Command$()
>
>Each element in the sArgs array will be a parameter.
>
>In other words, assume you drop the following files onto

your EXE:
>
> file1.txt file2.txt file3.txt
>
>you can then loop through the array like this
>
> Dim s As String
> for each s in sArgs
> DoSomething(s) ' Do something with the file.
> next
>
>This is actually easier than VB 6 or below, there it was

up to you to parse
>the command line, here most of the work is done for you.
>
>
>> I'm sorry to be such a newbie at this - I've worked with
>> VB6 and other Basics before but I seem to be having a hard
>> time finding the info I need for vb.net.

>
>There is plenty of info out there, just pick a topic and

Google it.
>
>> It looks like you no longer compile to an .exe. Instead you
>> do a Build, then run an Install/Deploy wizard to combine
>> all the parts to an .exe

>
>Where did you get that idea? And is simple untrue. Your

compiled application
>will be in the Bin directory under your solution directory.
>
>If your solution contains other projects referenced by

your main EXE project
>(Class libraries, Control libraries etc) they will be in

the Bin directory
>as well.
>
>
>
>Regards
>Brian W
>
>
>
>
>
>>
>> That makes testing this situation a little ackward as I
>> can't drop a file on till I get to that .exe
>>
>> Paul
>>

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Launch file location? My quick launch has lost it's way Toosun Dave Windows Vista General Discussion 7 27th Jan 2008 11:31 PM
How do I drag the Quick Launch toolbar off the Start Menu Viscount Windows Vista General Discussion 4 7th Mar 2007 09:36 PM
Drag and drop to create a link to a file in a cell of an Excel file paulaugust2003@yahoo.com Microsoft Excel Discussion 2 18th Sep 2005 03:44 PM
Cannot Drag and Drop to Start Menu or Quick Launch jfreibe Windows XP New Users 3 25th Nov 2003 01:36 AM
Re: Open File (Launch in Browser vs Launch in Native Program) bob Windows XP Internet Explorer 0 1st Oct 2003 09:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:27 AM.