c# - Remove file type from string -
this question has answer here:
- remove file extension file name string 11 answers
i'm calling list of strings server.
at moment i'm getting full name , file extension like:
image1.jpg
image2.png
test_folder.folder
i have code relies on knowing extension is, need access name of item i've selected out extension.
so far 2 attempts have been following:
_clickedfolder = listbox1.selecteditem.tostring() - "folder"; _clickedfolder.trim(new char[] { '.folder' });
but neither of these work.
what correct way take file extension away , have file name display?
use path
class:
string fnwithoutextension = path.getfilenamewithoutextension(path);
or
string extension = path.getextension(path);
Comments
Post a Comment