Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

passing the file associated with an app into a Windows Forms app

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Darren Mar-Elia (MVP) - 25 Jul 2006 00:18 GMT
I have a Windows Forms app that let's a user type the path to a file into a
inputbox. What I'd like to be able to do is, if the user sets an association
between a particular file type and my application in Explorer, I'd like to
be able to pre-populate the inputbox on Form Load with the name of the file
they did the "Open With" in in Explorer. I don't see an obvious way to do
this.
This is .net 1.1

Thanks!

Signature

Darren Mar-Elia
MS-MVP-Windows Server--Group Policy
Check out http://www.gpoguy.com -- The Windows Group Policy Information Hub:
FAQs, Training Videos, Whitepapers and Utilities for all things Group
Policy-related
And, the Windows Group Policy Guide is out from Microsoft Press!!! Check it
out at http://www.microsoft.com/mspress/books/8763.asp
GPOGUY Blog: http://blogs.dirteam.com/blogs/gpoguy

Trevor Benedict R - 25 Jul 2006 01:07 GMT
http://www.devx.com/vb2themax/Tip/18748

Regards,

Trevor Benedict R

>I have a Windows Forms app that let's a user type the path to a file into a
>inputbox. What I'd like to be able to do is, if the user sets an
[quoted text clipped - 5 lines]
>
> Thanks!
Darren Mar-Elia (MVP) - 25 Jul 2006 02:21 GMT
I tried that but it seems to only pass the full path of the executable
itself. What I'm after is the following. A user is in Explorer, they right
click on a file and choose Open With, and choose my app. When my app fires
up I'd like to pass the path of the file they right-clicked into the form.
That  GetCommandLineArgs method doesn't seem to pass the right info.

Darren

Signature

Darren Mar-Elia
MS-MVP-Windows Server--Group Policy
Check out http://www.gpoguy.com -- The Windows Group Policy Information Hub:
FAQs, Training Videos, Whitepapers and Utilities for all things Group
Policy-related
And, the Windows Group Policy Guide is out from Microsoft Press!!! Check it
out at http://www.microsoft.com/mspress/books/8763.asp
GPOGUY Blog: http://blogs.dirteam.com/blogs/gpoguy

> http://www.devx.com/vb2themax/Tip/18748
>
[quoted text clipped - 11 lines]
>>
>> Thanks!
Brian P. Hammer - 25 Jul 2006 04:53 GMT
Darren - The below code works every time for me.  It returns the full path,
including the file name when a user opens a file with my program.  I happen
to have a couple file extensions associated with my app.

FilePath = Microsoft.VisualBasic.Command().ToString
If FilePath = String.Empty Or FilePath = "" Then
   'Not Opened From File
   blnOpenFromSaved = False
Else
   blnOpenFromSaved = True
   NewFilePath = Replace(FilePath, """", "")
End If

MsgBox FilePath & VbCrLf & NewFilePath

>I tried that but it seems to only pass the full path of the executable
>itself. What I'm after is the following. A user is in Explorer, they right
[quoted text clipped - 19 lines]
>>>
>>> Thanks!
Darren Mar-Elia (MVP) - 25 Jul 2006 15:21 GMT
Thanks Brian-
Unfortunately, I'm using C# and there doesn't *appear* to be an equivalent
method there. I must be missing it. Can't imagine this would be so hard.

Darren

Signature

Darren Mar-Elia
MS-MVP-Windows Server--Group Policy
Check out http://www.gpoguy.com -- The Windows Group Policy Information Hub:
FAQs, Training Videos, Whitepapers and Utilities for all things Group
Policy-related
And, the Windows Group Policy Guide is out from Microsoft Press!!! Check it
out at http://www.microsoft.com/mspress/books/8763.asp
GPOGUY Blog: http://blogs.dirteam.com/blogs/gpoguy

> Darren - The below code works every time for me.  It returns the full
> path, including the file name when a user opens a file with my program.  I
[quoted text clipped - 34 lines]
>>>>
>>>> Thanks!
Patrice - 25 Jul 2006 15:54 GMT
Try :
http://msdn2.microsoft.com/en-us/library/system.environment.commandline.aspx
(includes a code sample)

Is this correct ?

If not I believe this could be because the file association must explicitely
specify that the file name should be passed i.e. the open command for your
application should be "c:\path\yourapp.exe" "%1" not just
"c:\path\yourapp.exe".

Signature

Patrice

> Thanks Brian-
> Unfortunately, I'm using C# and there doesn't *appear* to be an equivalent
[quoted text clipped - 41 lines]
>>>>>
>>>>> Thanks!
Darren Mar-Elia (MVP) - 25 Jul 2006 16:14 GMT
Patrice-
I had tried that before and I wasn't getting the results I needed, but I
think I see why now--my mistake because of a debugging problem--it is
working with the GetComandLineArgs method.

Thanks to all who helped.

Darren
Signature

Darren Mar-Elia
MS-MVP-Windows Server--Group Policy
Check out http://www.gpoguy.com -- The Windows Group Policy Information Hub:
FAQs, Training Videos, Whitepapers and Utilities for all things Group
Policy-related
And, the Windows Group Policy Guide is out from Microsoft Press!!! Check it
out at http://www.microsoft.com/mspress/books/8763.asp
GPOGUY Blog: http://blogs.dirteam.com/blogs/gpoguy

> Try :
> http://msdn2.microsoft.com/en-us/library/system.environment.commandline.aspx 
[quoted text clipped - 53 lines]
>>>>>>
>>>>>> Thanks!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.