I'm looking for a way to return fileName from full path but without extension.
private static string ReturnFileNameWithoutExtension(string varFullPathToFile) {
string fileName = new FileInfo(varFullPathToFile).Name;
string extension = new FileInfo(varFullPathToFile).Extension;
return fileName.Replace(extension, "");
}
Is there more bullet proof solution then replacing extension with empty string?
One More solution
string fileName = new FileInfo(varFullPathToFile).Name;
fileName=fileName.Substring(0, fileName.LastIndexOf("."));
return Path.GetFileNameWithoutExtension (fullpath);
i'm using System.IO.Path.GetFileNameWithoutExtension(filename);
You're looking for Path.GetFileNameWithoutExtension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With