Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Extracting File Names...
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00973941
Message ID:
00973950
Vues:
12
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform