473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Opening multiple files with my applicaton

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
10 3646
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
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
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


"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
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
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

"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


"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SenthilVel | last post by:
HI all in my visual studio DOtnet . i am not able to open multiple cs files in the projects , its openings only one cs file at a time, can any one let me know, what setttings i must do in order...
0
by: vinX | last post by:
Ok, i am making a file renaming utility, you can add filesize (in MB o KB), filepath, creation date and/or time, a counter, parent folder, th original name etc... I put the program in the...
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
3
by: the friendly display name | last post by:
We offer files (self-made programs), the customer needs to be authorized to be able to download them. We're offering currently over 20 files, each file is in a certain group.. the customer can be...
1
by: UJ | last post by:
I am doing development on a machine and everything was working fine. The name of the project was ECS to I made all my references as ~/ECS/... Worked great. Put it on the final server running...
3
emaghero
by: emaghero | last post by:
Hello all, I want to open multiple txt files with similar names in C++ I have attempted this with the following code //Create as many txt files as there are valid propagation constants...
1
by: giddy | last post by:
Hi , I've read this a long time ago , read it again:...
2
by: michael40card | last post by:
First of all... Hi I am attempting to create a html 'gallery creater' for a program... everythink was going ok, seems to work. the only trouble is i cannot find any way of allowing the user to...
4
by: Myxamatosis | last post by:
I'll skip the nitty gritty, but here's the outline of the program int main( int Argc, char *Arg) { ifstream indata; cout << "Command line contained " << Argc << " tokens\n\n"; cout...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.