Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

extracting file name from the URL

Hi,

From the below URL I want to grab the file name CRS235 without file extension. I think this can be done using regular expressions. But, is there
a function that can directly extract this in C#.NET?

http://www.cs.ndsu.nodak.edu/students/CRS235.txt

Any weblink on this would be helpful.

Thanks,
[336 byte] By [srinivasc_it] at [2007-11-11 10:18:38]
# 1 Re: extracting file name from the URL
srinivasc_it,

The Path class's GetFileNameWithoutExtension seems to work with this input.

For example:

MsgBox(System.IO.Path.GetFileNameWithoutExtension(" http://www.cs.ndsu.nodak.edu/students/CRS235.txt"))

Kerry Moorman
kmoorman at 2007-11-11 20:48:12 >