The Name property of the FileInfo class will return the filename and extention withouth the path.
System.String sPathAndFile = "c:\temp\filename.txt";
System.String sJustName;
FileInfo oFileInfo = new FileInfo(cFileName);
sJustName = oFileInfo.Name;
Now this isn't exactly a one-liner but this is: <s>
System.String sPathAndFile = "c:\temp\filename.txt"; System.String sJustName; FileInfo oFileInfo = new FileInfo(cFileName); sJustName = oFileInfo.Name;
Hope this helps
Einar
>If I have a string:
>
> "c:\temp\filename.txt"
>
>Has anyone come up with a way of extracting only "filename.txt" with a one-liner?
>
>I know I can use LastIndexOf and SubString but I was just wondering if there was a one liner with Regex or something...
Semper ubi sub ubi.