Beispiel #1
0
        // Files
        private void AddFiles(object obj)
        {
            try
            {
                FileData root = (FileData)obj;

                // Folders
                foreach (FileData folder in root.GetFolders())
                {
                    lock (FolderMap)
                        FolderMap.Add(folder.Id, folder);

                    AddFiles(folder);
                }

                // Files
                foreach (FileData file in root.GetFiles())
                {
                    // Do not verify if the file is accessible
                    lock (FileMap)
                        FileMap.Add(file.Id, file);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            OnFile();
        }
Beispiel #2
0
        // Folders
        public void AddFolder(FileData data)
        {
            FolderMap.Add(data.Id, data);
            SharedFolders.Add(data);
            SharedFolders.Sort();

            try
            {
                Thread thread = new Thread(new ParameterizedThreadStart(AddFiles))
                {
                    Priority = ThreadPriority.BelowNormal, IsBackground = true
                };
                thread.Start(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }