Exemple #1
0
 public void AddUSBProfile(USBProfile p)
 {
     lock (syncLock)
     {
         AvailableProfiles[p] = 0;
     }
 }
Exemple #2
0
        public USBProfile CreateProfile(string deviceID, string profileName, string rootDestination, string[] ignoredFolders, string[] ignoredExtensions)
        {
            Log.WriteLine("Attempting to create file called: " + profileDirectory + "\\" + profileName + Program.PROFILE_EXTENSION);
            SettingsFile sf = new SettingsFile(profileDirectory + "\\" + profileName + Program.PROFILE_EXTENSION);

            sf.SetKey("DeviceID", deviceID);
            sf.SetKey("ProfileName", profileName);
            sf.SetKey("RootDestination", rootDestination);
            Log.WriteLine("IgnoredFolders is now: " + ignoredFolders);
            sf.SetKeyArray("IgnoredFolders", ignoredFolders);
            sf.SetKeyArray("IgnoredExtensions", ignoredExtensions);
            sf.Save();
            usbProfiles[profileName] = sf;

            USBProfile p = new USBProfile();

            p.DeviceID        = deviceID;
            p.DestinationRoot = rootDestination;
            foreach (string igDir in ignoredFolders)
            {
                p.IgnoredFolders.Add(igDir);
            }
            foreach (string igExt in ignoredExtensions)
            {
                p.IgnoredExtensions.Add(igExt);
            }
            return(p);

            ;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            //USBBackup usb = new USBBackup(Program.CURRENT_DIR);
            string[] array = new string[ignoreListBox.Items.Count];
            for (int i = 0; i < ignoreListBox.Items.Count; i++)
            {
                array[i] = (string)ignoreListBox.Items[i];
            }
            Console.WriteLine("IgnoredFolders is now: " + array);
            USBProfile p = usb.CreateProfile(deviceIDTextBox.Text, profileNameTextBox.Text, destinationRootTextBox.Text + "\\", array, new string[] { });

            this.Hide();
            this.Dispose();
            mw.PopulateListBox();
            usbl.AddUSBProfile(p);
        }
Exemple #4
0
 public void PerformBackup(USBProfile p, DriveInfo di)
 {
     //if (mw != null)
     //{
     //    mw.BackupStarted();
     //}
     BackupInProgress = true;
     //Copy(p.DestinationRoot, di.RootDirectory.ToString(),p.IgnoredFolders,p.IgnoredExtensions);
     filesInDrive = SafeWalk.EnumerateFiles(di.RootDirectory.ToString(), "*.*", SearchOption.AllDirectories).Count();
     if (mw != null)
     {
         mw.BackupStarted();
     }
     DirectoryCopy(di.RootDirectory.ToString(), p.DestinationRoot, true, p.IgnoredFolders, p.IgnoredExtensions);
     BackupInProgress = false;
     if (mw != null)
     {
         mw.BackupFinished();
     }
 }
Exemple #5
0
        public USBBackup(String profileDirectory)
        {
            this.profileDirectory = profileDirectory;
            usbProfiles           = new Dictionary <string, SettingsFile>();
            actualProfiles        = new List <USBProfile>();

            Log.WriteLine(profileDirectory);

            foreach (String file in Directory.GetFiles(profileDirectory))
            {
                if (Path.GetExtension(file) != Program.PROFILE_EXTENSION)
                {
                    Log.WriteLine("Found file that is not a profile: " + file);
                    continue;
                }
                try
                {
                    SettingsFile sf = new SettingsFile(file);
                    if (sf.GetKey <string>("ProfileName") != default(string))
                    {
                        usbProfiles.Add(sf.GetKey <string>("ProfileName"), sf);
                        USBProfile p = new USBProfile();
                        p.DeviceID        = sf.GetKey <string>("DeviceID");
                        p.DestinationRoot = sf.GetKey <string>("RootDestination");
                        foreach (string dir in sf.GetKeyArray <string>("IgnoredFolders"))
                        {
                            p.IgnoredFolders.Add(dir);
                        }
                        foreach (string ext in sf.GetKeyArray <string>("IgnoredExtensions"))
                        {
                            p.IgnoredExtensions.Add(ext);
                        }
                        actualProfiles.Add(p);
                    }
                }catch (Exception e)
                {
                    Log.WriteLine("Caught exception whilst trying to load usb profiles. " + e.Message);
                }
            }
            this.profileDirectory = profileDirectory;
        }