reClarifying - double click on a file to load in my app?

E

Elmo Watson

I've got TextFiles associated with my application - however, when I double
click on the files, it just opens my application, and does not load the file
inside my application. Here's my sub:

Private Sub GetOutsideFile(ByVal FileArgs() As String)
Dim s As String
For Each s In FileArgs
If s.EndsWith("txt") Then
CreateNewDocument(s)
End If
Next
End Sub

Then, in the form load, I put this line:
GetOutsideFile(Environment.GetCommandLineArgs())

What am I missing here?
 
J

Jeff Gaines

I've got TextFiles associated with my application - however, when I double
click on the files, it just opens my application, and does not load the
file inside my application. Here's my sub:

Private Sub GetOutsideFile(ByVal FileArgs() As String)
Dim s As String
For Each s In FileArgs
If s.EndsWith("txt") Then
CreateNewDocument(s)
End If
Next
End Sub

Then, in the form load, I put this line:
GetOutsideFile(Environment.GetCommandLineArgs())

What am I missing here?

Have you stepped through GetOutsideFile in the debugger to see what
parameters are passed to it?
 
E

Elmo Watson

The only way I know how to test this functionality, is with a compiled,
installed application.
How can I double click on a file and step through my code?
 
J

Jeff Gaines

The only way I know how to test this functionality, is with a compiled,
installed application.
How can I double click on a file and step through my code?

Good point!

What about adding a List Box to your app temporarily and populating it in
GetOutsideFile:

Private Sub GetOutsideFile(ByVal FileArgs() As String)
Dim s As String
For Each s In FileArgs
If s.EndsWith("txt") Then
// For debugging
lstTest.Items.Add(s)
CreateNewDocument(s)
End If
Next
End Sub

You may have to tweak it a bit, I am more familiar with C#.
 
E

Elmo Watson

I tried:
Dim retText As String
retText = retText .Join("-", FileArgs)
MessageBox.Show("There are " & UBound(FileArgs) & " files")
MessageBox.Show(retText)

It looks to me, like the Environment.GetCommandLineArgs is only returning
one file - -
myFullappPathAndEXE - And one file (no matter how many were highligted -
then 'open with')

I would have expected, if I had multiple files highlighted, that it would
have multiple files in the returned data.

Is there another command to get the full list of highlighted files (other
than GetCommandLineArgs) - or is there some way to actually get all the
highlighted files?

Ideas?????

(again, my original code was:
Private Sub GetOutsideFile(ByVal FileArgs() As String)
Dim s As String
For Each s In FileArgs
If s.EndsWith("txt") Then
CreateNewDocument(s)
End If
Next
End Sub

Then, in the form load, I put this line:
GetOutsideFile(Environment.GetCommandLineArgs())
)
 

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

Top