The following is some code that searches an existing string for two other
strings (start marker and end marker), then gets only the required piece out
of the middle.
const string MODULE_LABEL = "/module";
// Get the command line parameters/arguments
ls_Argument = Environment.Get CommandLineArgs ();
ls_Command_Line = String.Join(" ", ls_Argument);
ls_Command_Line = ls_Command_Line .Trim();
// Find the beginning of the /module parameter value
li_Position_Sta rt = ls_Command_Line .IndexOf(MODULE _LABEL);
if (li_Position_St art == -1)
return -2011;
li_Position_Sta rt += MODULE_LABEL.Le ngth;
// Find end of the /module parameter value
li_Position_End = ls_Command_Line .IndexOf("/", li_Position_Sta rt + 1);
if (li_Position_En d == -1)
{
// use remainder of string
li_Position_End = ls_Command_Line .Length;
}
else
{
li_Position_End --;
}
// Get Module parameter value
ls_Parameter_Va lue = ls_Command_Line .Substring(li_P osition_Start,
li_Position_End - li_Position_Sta rt);
ls_Parameter_Va lue = ls_Parameter_Va lue.Trim();
"Netmonster " <ne***********@ yahoo.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Hello,
How do I parse a string that contains a URL and get the filename only?
i.e.
string tmp = "http://test.com/downloads/test.exe";
I just want the test.exe..
Thanks in advance.
KC