/// <summary> /// Sets a new path for the list view /// </summary> /// <param name="newPath">Path to be set</param> public void setPath(ref string newPath) { if (newPath == null || newPath == "" || !Directory.Exists(newPath)) { return; } if (newPath.Length == 2) { if (char.IsLetter(newPath[0]) && newPath[1] == ':') { newPath = newPath + Path.DirectorySeparatorChar; } } //Skip this for now on networks if (!isNetworkPath(newPath)) { //fix casing of the path if user entered it newPath = fixPathCase(newPath); } //Same path, ignore if (Helper.ReadProperty(ConfigKeyConstants.LAST_DIRECTORY_KEY).ToLower() == newPath.ToLower()) { return; } else { Helper.WriteProperty(ConfigKeyConstants.LAST_DIRECTORY_KEY, newPath); Environment.CurrentDirectory = newPath; } }
/// <summary> /// Sets a new path for the list view /// </summary> /// <param name="path">Path to be set</param> public void SetPath(ref string path) { if (path == null || path == "" || !Directory.Exists(path)) { return; } if (path.Length == 2) { if (char.IsLetter(path[0]) && path[1] == ':') { path = path + Path.DirectorySeparatorChar; } } DirectoryInfo currentpath = new DirectoryInfo(path); //Skip this for now on networks if (!path.StartsWith("\\\\")) { //fix casing of the path if user entered it string fixedpath = ""; while (currentpath.Parent != null) { fixedpath = currentpath.Parent.GetDirectories(currentpath.Name)[0].Name + Path.DirectorySeparatorChar + fixedpath; currentpath = currentpath.Parent; } fixedpath = currentpath.Name.ToUpper() + fixedpath; fixedpath = fixedpath.TrimEnd(new char[] { Path.DirectorySeparatorChar }); if (fixedpath.Length == 2) { if (char.IsLetter(fixedpath[0]) && fixedpath[1] == ':') { fixedpath = fixedpath + Path.DirectorySeparatorChar; } } path = fixedpath; } //Same path, ignore if (Helper.ReadProperty(Config.LastDirectory).ToLower() == path.ToLower()) { return; } else { Helper.WriteProperty(Config.LastDirectory, path); Environment.CurrentDirectory = path; } }