How to parse url

darknuke

Well-known member
Joined
Oct 3, 2003
Messages
68
PHP:
http://www.mysite.com/myfolder/myotherfolder/[b]myfile.exe[/b]

How can I get myfile.exe into a variable?
 
C#:
/// <summary>
			/// Returns just the filename excluding the extention.  Option to include extention.  
			/// Put any string in second argument.  Could use Path.GetFileName() instead.
			/// </summary>
			/// <param name="file"></param>
			/// <returns></returns>
			public static string CutOutFilename(string file)
			{
				string filename= "";
				int start= file.LastIndexOf(.);
				file= file.Remove(start, file.Length - start);
				start= file.LastIndexOf("\\");
				filename= file.Substring(start+1);
				return filename;
			}
			//----------
			public static string CutOutFilename(string file, string IncludeExt_) //change IncludeExt_ to bool would be better.
			{
				string filename= "";
				int start= file.LastIndexOf("\\");
				filename= file.Substring(start+1);
				return filename;
			}
 
Back
Top