private void getDirectories(string path) { Debug.WriteLine("DEBUG-WEBSOCKETHANDLER: GETTING DIRECTORIES FROM PATH: " + path); try { string[] dirs = Directory.GetDirectories(path); List <JsonDirectory> directorieswithpath = new List <JsonDirectory>(); foreach (string directory in dirs) { JsonDirectory directorywithpath = new JsonDirectory(); directorywithpath.dirname = directory.Replace(Path.GetDirectoryName(directory) + Path.DirectorySeparatorChar, ""); directorywithpath.path = directory; directorieswithpath.Add(directorywithpath); } JsonDirectories tosendover = new JsonDirectories(); tosendover.directories = directorieswithpath; SharedData.AddToMessageList(JsonConvert.SerializeObject(tosendover, Formatting.Indented)); } catch (Exception e) { Debug.WriteLine("DEBUG-WEBSOCKETHANDLER: COULD NOT FIND DIRS IN : " + path); Debug.WriteLine("DEBUG-WEBSOCKETHANDLER: " + e.ToString()); } }
private void getDrives() { DriveInfo[] allDrives = DriveInfo.GetDrives(); List <JsonDirectory> directorieswithpath = new List <JsonDirectory>(); foreach (DriveInfo drive in allDrives) { JsonDirectory directorywithpath = new JsonDirectory(); directorywithpath.dirname = drive.Name; directorywithpath.path = drive.Name; directorieswithpath.Add(directorywithpath); } JsonDirectories tosendover = new JsonDirectories(); tosendover.directories = directorieswithpath; SharedData.AddToMessageList(JsonConvert.SerializeObject(tosendover, Formatting.Indented)); }
private void createDirectory(string path) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); string[] dirs = Directory.GetDirectories(path); List <JsonDirectory> directorieswithpath = new List <JsonDirectory>(); foreach (string dir in dirs) { JsonDirectory directorywithpath = new JsonDirectory(); directorywithpath.dirname = dir.Split('\\')[dir.Split('\\').Length - 1]; directorywithpath.path = dir; directorieswithpath.Add(directorywithpath); } JsonDirectories tosendover = new JsonDirectories(); tosendover.directories = directorieswithpath; SharedData.AddToMessageList(JsonConvert.SerializeObject(tosendover, Formatting.Indented)); } }