使用我的应用程序打开多个文件 [英] Opening multiple files with my applicaton

查看:80
本文介绍了使用我的应用程序打开多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个有列表框的应用程序,当我双击一个

相关文件时,我希望他们的路径被添加到我的<列表框中br />
申请。


这个代码在我尝试打开单个时效果很好文件与我的应用程序

用于获取命令行参数以获取文件路径:

Dim cla As String()= Environment.GetCommandLineArgs()

如果cla.Length 1那么

ListBox1.Items.Add(cla(1))

结束如果


但是在同一个

时间打开多个文件时这不起作用。


假设我按下CTRL +左选择3个文件鼠标然后打开

with我的应用程序,然后我希望这三个文件的路径必须是

作为项目添加到列表框中。 (列表框将有3个项目,项目是

文件路径)


我希望你能提供帮助。


问候。

解决方案

尝试以下内容

Dim cla As String()= Environment.GetCommandLineArgs()

如果cla.Length> = 1那么

如果cla.Length = 1那么

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

结束如果


当有多个文件时,第一项是其他文件夹

名称

所以请检查1是否需要一个完整的

如果更多需要一个并添加名称


如果文件位于文件夹的根目录中因此已经反斜杠

还要检查:iif(cla(1).endswith(" \"),"",&quo t; \")

Jan

" kimiraikkonen" < ki ************* @ gmail.comschreef in bericht

news:56 ***************** ***************** @ c4g2000h sg.googlegroups.com ...




我有一个有列表框的应用程序,当我双击一个

相关文件时,我希望他们的路径被添加到我的

应用程序的列表框中。 br />

当我尝试打开单个时,此代码很有效。文件与我的应用程序

用于获取命令行参数以获取文件路径:

Dim cla As String()= Environment.GetCommandLineArgs()

如果cla.Length 1那么

ListBox1.Items.Add(cla(1))

结束如果


但是在同一个

时间打开多个文件时这不起作用。


假设我按下CTRL +左选择3个文件鼠标然后打开

with我的应用程序,然后我希望这三个文件的路径必须是

作为项目添加到列表框中。 (列表框将有3个项目,项目是

文件路径)


我希望你能提供帮助。


问候。


12月26日上午9:47,JR < xx .... @ xx.xxwrote:


尝试以下内容

Dim cla As String()= Environment.GetCommandLineArgs( )

如果cla.Length> = 1那么

如果cla.Length = 1那么

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

结束如果


当有超过1个文件时,第一个项目是其他人的文件夹

名称

所以请检查1是否需要一个完整的

如果多拿一个并添加名称


如果文件在根目录中该文件夹已经有一个反斜杠因此

也检查:iif(cla(1).endswith(" \"),""," \")


Jan


" kimir aikkonen" < kimiraikkone ... @ gmail.comschreef in berichtnews:56 ********************************** @ c 4g2000hsg.googlegroups.com ...




我有一个应用程序,它有一个列表框,当我双击一个

关联的文件,我想将他们的路径添加到我的

应用程序的列表框中。


当我尝试打开单个时,此代码效果很好文件与我的应用程序

,它用于获取命令行参数以获取文件路径:


Dim cla As String()= Environment.GetCommandLineArgs()

如果cla.Length 1那么

ListBox1.Items.Add(cla(1))

如果$ b结束$ b


但是在同一个

时间打开多个文件时这不起作用。


假设我按下CTRL +左键选择3个文件,然后用打开

我的应用程序,然后我希望这三个文件的路径必须是

作为项目添加到列表框中。 (列表框将有3个项目,项目是

文件的路径)


我希望你能提供帮助。


问候。



JR,


尝试了你给的代码,但它没有用。如果我修改为

" cla> = 1"我得到超出界限的指数错误,如果icla> 1没有错误

但没有多个文件的路径添加到我的列表框中。


将多个文件的路径添加到列表框中的正确编码是什么

当我打开应用程序的时候?


12月26日上午10点08分,kimiraikkonen< kimiraikkone ... @ gmail.comwrote :


12月26日上午9:47,JR < xx .... @ xx.xxwrote:


尝试以下内容

Dim cla As String()= Environment.GetCommandLineArgs( )

如果cla.Length> = 1那么

如果cla.Length = 1那么

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

结束如果


当有多个文件时,第一项是文件夹,其他文件是

这个名字是

所以检查1是否需要一个完整的

如果多拿一个并添加名称


如果文件在根文件夹中已经有反斜杠那么

也请检查:iif(cla(1).ends with(" \"),""," \")


Jan


" kimiraikkonen" < kimiraikkone ... @ gmail.comschreef in berichtnews:56 ********************************** @ c 4g2000hsg.googlegroups.com ...




我有一个应用程序它有一个列表框,当我双击

相关文件时,我希望他们的路径被添加到我的

应用程序的列表框中。


当我尝试打开单个时,此代码效果很好文件与我的应用程序

用于获取命令行参数以获取文件路径:


Dim cla As String()= Environment.GetCommandLineArgs()

如果cla.Length 1则

ListBox1.Items.Add(cla(1))

结束如果


但这不起作用同时打开多个文件

时间。


假设我按下CTRL +左键选择3个文件然后打开 />
with我的应用程序,然后我希望这三个文件的路径必须是

作为项目添加到列表框中。 (列表框将有3个项目,项目是

文件的路径)


我希望你能提供帮助。


问候。



JR,


试过你给的代码,但它不起作用。如果我修改为

" cla> = 1"我得到超出界限的指数错误,如果icla> 1没有错误

但没有多个文件的路径添加到我的列表框中。


将多个文件的路径添加到列表框中的正确编码是什么
当我用应用程序打开tem时



注意:在正常文件夹中选择多个文件。


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.

解决方案

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.


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 ?


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.


这篇关于使用我的应用程序打开多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆