c# - Trim off last directory/folder without using GetParent() -


i trying emulate "cd .." does, without using getparent().

input: /var/mobile/documents/

actual output: /var/mobile/documents/

desired output: /var/mobile/

    public arraylist jumpupdirectory()     {         arraylist directorylisting = new arraylist();         stringbuilder storedpath = new stringbuilder();                      foreach (var directories in storedpreviousdirectory.split('/'))         {             storedpath.append(directories + "/");                         }          storedpath.replace("//", "/");         directorylisting = iphonefilesystembrowse(storedpreviousdirectory);          return directorylisting;     } 

try this:

string input = "/var/mobile/documents/"; var parts = input.split(new []{'/'}, stringsplitoptions.removeemptyentries).tolist(); parts.removeat(parts.count - 1); string output = string.concat("/", string.join("/", parts), "/"); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -