예제 #1
0
        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());
            }
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
            }
        }