I’m using the following code to trim the file extensions of some items . It latter pulls off a database. It seems database is not pulling the “.”. In short I want file.ext to be turned to file but the closest Ive gotten is file “.” which isn’t working for me
string linkWithoutExtension = System.IO.Path.ChangeExtension(path, "");
Thanks for any help.
Edit
Ok I changed it to the following but now its giving me an even weirder problem. Its renaming the path. So instead of it being (site.com/type/subtype/type1/video/videoname.) like I got before I now get (site.com/type/subtype/elsewhere/nothere/videoname).
string linkWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(path);
There’s a
Path.GetFileNameWithoutExtensionmethod soAs Pointed out by peter i forgot about the original directory so you can use
Path.CombineandPath.GetDirectoryName(path)as shown in peters answer