By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,345 Members | 1,256 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,345 IT Pros & Developers. It's quick & easy.

Opening multiple files with my applicaton

P: n/a
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.

This code works good when i try to open a "single" file with my app
which works to get commandline arguments to get file paths:

Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length 1 Then
ListBox1.Items.Add(cla(1))
End if

But this doesn't work while opening more than one files at the same
time.

Assume i select 3 files with pressing CTRL + left mouse and then "open
with" my application, then i want these three files' paths must be
added as items into the listbox. (listbox will have 3 items, items are
the paths of files)

I hope you can help.

Regards.
Dec 25 '07 #1
Share this Question
Share on Google+
10 Replies

P: n/a
JR
try the following
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length >= 1 Then
If cla.Length = 1 Then
ListBox1.Items.Add(cla(1))
else
for n as integer=2 to cla.length
ListBox1.Items.Add(cla(1) & iif(cla(1).endswith("\"),"","\") &
cla(n))
next
End if

when there is more than 1 file the first item is the folder the others are
the name
so check if 1 take one complete
if more take one and add the names

if the files are in the root the folder has already a backslash therefore
check also with: iif(cla(1).endswith("\"),"","\")
Jan
"kimiraikkonen" <ki*************@gmail.comschreef in bericht
news:56**********************************@c4g2000h sg.googlegroups.com...
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.

This code works good when i try to open a "single" file with my app
which works to get commandline arguments to get file paths:

Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length 1 Then
ListBox1.Items.Add(cla(1))
End if

But this doesn't work while opening more than one files at the same
time.

Assume i select 3 files with pressing CTRL + left mouse and then "open
with" my application, then i want these three files' paths must be
added as items into the listbox. (listbox will have 3 items, items are
the paths of files)

I hope you can help.

Regards.
Dec 26 '07 #2

P: n/a
On Dec 26, 9:47 am, "JR" <xx....@xx.xxwrote:
try the following
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length >= 1 Then
If cla.Length = 1 Then
ListBox1.Items.Add(cla(1))
else
for n as integer=2 to cla.length
ListBox1.Items.Add(cla(1) & iif(cla(1).endswith("\"),"","\") &
cla(n))
next
End if

when there is more than 1 file the first item is the folder the others are
the name
so check if 1 take one complete
if more take one and add the names

if the files are in the root the folder has already a backslash therefore
check also with: iif(cla(1).endswith("\"),"","\")

Jan

"kimiraikkonen" <kimiraikkone...@gmail.comschreef in berichtnews:56**********************************@c 4g2000hsg.googlegroups.com...
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.
This code works good when i try to open a "single" file with my app
which works to get commandline arguments to get file paths:
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length 1 Then
ListBox1.Items.Add(cla(1))
End if
But this doesn't work while opening more than one files at the same
time.
Assume i select 3 files with pressing CTRL + left mouse and then "open
with" my application, then i want these three files' paths must be
added as items into the listbox. (listbox will have 3 items, items are
the paths of files)
I hope you can help.
Regards.
JR,

Tried the code you've given but it doesn't work. If i modify as
"cla>=1" i get "index outside of bounds" error, if i "cla>1" no error
but no multiple files' paths added to my listbox.

What's the correct coding to add multiple files' paths into listbox
when i open tem with application ?
Dec 26 '07 #3

P: n/a
On Dec 26, 10:08 am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Dec 26, 9:47 am, "JR" <xx....@xx.xxwrote:
try the following
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length >= 1 Then
If cla.Length = 1 Then
ListBox1.Items.Add(cla(1))
else
for n as integer=2 to cla.length
ListBox1.Items.Add(cla(1) & iif(cla(1).endswith("\"),"","\") &
cla(n))
next
End if
when there is more than 1 file the first item is the folder the others are
the name
so check if 1 take one complete
if more take one and add the names
if the files are in the root the folder has already a backslash therefore
check also with: iif(cla(1).endswith("\"),"","\")
Jan
"kimiraikkonen" <kimiraikkone...@gmail.comschreef in berichtnews:56**********************************@c 4g2000hsg.googlegroups.com...
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.
This code works good when i try to open a "single" file with my app
which works to get commandline arguments to get file paths:
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length 1 Then
ListBox1.Items.Add(cla(1))
End if
But this doesn't work while opening more than one files at the same
time.
Assume i select 3 files with pressing CTRL + left mouse and then "open
with" my application, then i want these three files' paths must be
added as items into the listbox. (listbox will have 3 items, items are
the paths of files)
I hope you can help.
Regards.

JR,

Tried the code you've given but it doesn't work. If i modify as
"cla>=1" i get "index outside of bounds" error, if i "cla>1" no error
but no multiple files' paths added to my listbox.

What's the correct coding to add multiple files' paths into listbox
when i open tem with application ?
Note: Multiple files are selected in the same folder as normal.
Dec 26 '07 #4

P: n/a


"kimiraikkonen" wrote:
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.

This code works good when i try to open a "single" file with my app
which works to get commandline arguments to get file paths:

Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length 1 Then
ListBox1.Items.Add(cla(1))
End if

But this doesn't work while opening more than one files at the same
time.
You are only adding the first item from the command line. Change your code
to:

Dim cla As String() = Environment.GetCommandLineArgs()
Dim idx as Integer

If cla.Length 1 Then
for idx = 1 to (cla.Length-1)
ListBox1.Items.Add(cla(idx))
next idx
endif
Dec 26 '07 #5

P: n/a
On Dec 26, 6:10 pm, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"kimiraikkonen" wrote:
Hi,
I have an app which has a listbox and when i double click an
associated fileS, i want their paths to be added into listbox in my
application.
This code works good when i try to open a "single" file with my app
which works to get commandline arguments to get file paths:
Dim cla As String() = Environment.GetCommandLineArgs()
If cla.Length 1 Then
ListBox1.Items.Add(cla(1))
End if
But this doesn't work while opening more than one files at the same
time.

You are only adding the first item from the command line. Change your code
to:

Dim cla As String() = Environment.GetCommandLineArgs()
Dim idx as Integer

If cla.Length 1 Then
for idx = 1 to (cla.Length-1)
ListBox1.Items.Add(cla(idx))
next idx
endif
Hi Family Tree Mike,
Tried your code but only one file's path is added into listbox when i
try to open more than one file "with" my app by selecting CTRL + mouse
left click.

The thing i want to implement is exactly like when you select more
than one files, then "open with" Windows Media Player, then these
files are added into playlist of WMP. The same strategy i want to see
worked.(I only want to add paths of fileS).

Thanks.
Dec 26 '07 #6

P: n/a
The thing i want to implement is exactly like when you select more
than one files, then "open with" Windows Media Player, then these
files are added into playlist of WMP. The same strategy i want to see
worked.(I only want to add paths of fileS).

Thanks.
I hate to say this, but Windows Media Player behaves in the same way for me
when using "Open with Windows Media Player". It behaves as you want when
selecting "Play with Media Player". I am unsure how the modes are different
when starting from Explorer.

Dec 26 '07 #7

P: n/a

"kimiraikkonen" <ki*************@gmail.comkirjoitti viestissä
news:00**********************************@b40g2000 prf.googlegroups.com...

Replace %1 with %L from registry and see what kind of parameters you get.
Also try to change your application to single instance mode from project's
properties.

-Teemu

Dec 26 '07 #8

P: n/a


"Teemu" wrote:
>
"kimiraikkonen" <ki*************@gmail.comkirjoitti viestissä
news:00**********************************@b40g2000 prf.googlegroups.com...

Replace %1 with %L from registry and see what kind of parameters you get.
Also try to change your application to single instance mode from project's
properties.

-Teemu
Changing the test application to single instance mode, for me, had no effect
but it seemed like a logical thought. What registry entry are you talking
about changing the %1 to %L? I wasn't working in the registry.

Dec 27 '07 #9

P: n/a
On Dec 27, 2:00 pm, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"Teemu" wrote:
"kimiraikkonen" <kimiraikkone...@gmail.comkirjoitti viestissä
news:00**********************************@b40g2000 prf.googlegroups.com...
Replace %1 with %L from registry and see what kind of parameters you get..
Also try to change your application to single instance mode from project's
properties.
-Teemu

Changing the test application to single instance mode, for me, had no effect
but it seemed like a logical thought. What registry entry are you talking
about changing the %1 to %L? I wasn't working in the registry.
I haven't tried but maybe you can take a look at Winamp's "Play in
Winamp" action in tools->folder options-"file types" for mp3
extension -advanced -edit section.
It used "%1" parameter separately. But this is not enough because you
have to integrate this parameter "same thing" during the installation
of your software via installers or manually.
Dec 27 '07 #10

P: n/a
On Dec 27 2007, 2:00 pm, Family Tree Mike
<FamilyTreeM...@discussions.microsoft.comwrote:
"Teemu" wrote:
"kimiraikkonen" <kimiraikkone...@gmail.comkirjoitti viestissä
news:00**********************************@b40g2000 prf.googlegroups.com...
Replace %1 with %L from registry and see what kind of parameters you get..
Also try to change your application to single instance mode from project's
properties.
-Teemu

Changing the test application to single instance mode, for me, had no effect
but it seemed like a logical thought. What registry entry are you talking
about changing the %1 to %L? I wasn't working in the registry.
Hi again, does somebody know how to open "multiple files" with my app
using "open with" located in first context menu?
The code Family Tree Mike suggested works fine with "send to" method,
but "open with" doesn't work and only opens a single file with my
app(adding files' paths into my app's listbox), as Teemu stated we
must add %1 or L parameter entries.

How to do that and has somebody accomplished this?

Thanks.
Jan 4 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.