public UpperDirectory GetUpperDirectory() { string path = this.Path; int count = 0; foreach (char c in path) { if (c == '\\') { count++; } } if (count == 1) { path = path.Substring(0, path.LastIndexOf(@"\") + 1); } else if (count > 1) { path = path.Substring(0, path.LastIndexOf(@"\")); } UpperDirectory upDir = new UpperDirectory(path); return(upDir); }
/// <summary> /// Get items in directory and it's upper directory /// </summary> private void GetItems() { if (currFilesView == FilesViewL) { directoriesL = dirL.GetDirectories(); filesL = dirL.GetFiles(); upDirL = dirL.GetUpperDirectory(); } else { directoriesR = dirR.GetDirectories(); filesR = dirR.GetFiles(); upDirR = dirR.GetUpperDirectory(); } }