Link to home
Start Free TrialLog in
Avatar of Andy Brown
Andy BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Extracting a hyperlink from the command line

I'm new to c# and need a bit of guidance on something that I fear is very obvious (but haven't figured out).  I want to pass a hyperlink via the command line to a variable called strHyperlink.  I was thinking of something like this for the command line:

D:\Testbed\Sandbox.exe http://website.com

I have added the variable to the Form class
string strHyperlink = Environment.CommandLine;

Open in new window


However, when I try to view the switch using the following:

var result = MessageBox.Show(strHyperlink, "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);

Open in new window


I get:

"D:\Testbed\Sandbox.exe http://website.com"

Can someone please let me know how to get the hyperlink (in the cleanest possible way).  Thank you.
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Dim arguments As String() = Environment.GetCommandLineArgs()
arguments(1) contains the hyperlink
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Andy Brown

ASKER

Great stuff - thank you.
duh, I gave you the vb version for some reason.
Note you also need to check that there are more than 1 arguments (the first one is the application iteself)
welcome happy to help.
Thank you both.