C# FolderBrowserDialog: Getting only the selected folder's name -


as title states need last folder in string open folder dialog creates when user selects folder. instance:

string folder; folderbrowserdialog fbd = new folderbrowserdialog(); fbd.rootfolder = system.environment.specialfolder.mycomputer; if (fbd.showdialog() == dialogresult.ok) {     folder = fbd.selectedpath; } 

i want trim before last "\" leave me selected folder's name. thank help

you can use path.getfilename this:

folder = path.getfilename(fbd.selectedpath); 

this might seem counter-intuitive, path.getfilename() returns text right of final path separator.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -