예제 #1
0
 private void lnklblRootPreferences_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         RootPreferences getPreferences = new RootPreferences();
         getPreferences.Services.Add(amazon);
         getPreferences.Services.Add(dropbox);
         getPreferences.Services.Add(googledrive);
         getPreferences.Services.Add(onedrive);
         getPreferences.Services.Add(copydrive);
         getPreferences.ShowDialog();
     }
     catch (Exception ex)
     {
         LogUtils.Error(ex.Message, ex);
     }
 }
예제 #2
0
        private void tmrRootWatcher_Tick(object sender, EventArgs e)
        {
            try
            {
                this.tmrRootWatcher.Stop();
                bool            askforService   = ApplicationSettings.AskForPreferredService;
                string          defaultService  = ApplicationSettings.PreferredService;
                DirectoryInfo   diMappedDirInfo = new DirectoryInfo(ApplicationSettings.MappedFolder);
                List <FileInfo> TopLevelFiles   = new List <FileInfo>(diMappedDirInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly));

                TopLevelFiles = (from f in TopLevelFiles
                                 where string.Compare(f.Name, "desktop.ini", true) != 0
                                 select f).ToList();

                if (TopLevelFiles.Count > 0)
                {
                    if (askforService || string.IsNullOrEmpty(defaultService))
                    {
                        RootPreferences getPreferences = new RootPreferences();
                        getPreferences.Services.Add(amazon);
                        getPreferences.Services.Add(dropbox);
                        getPreferences.Services.Add(googledrive);
                        getPreferences.Services.Add(onedrive);
                        getPreferences.Services.Add(copydrive);

                        if (getPreferences.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }
                    }

                    foreach (FileInfo fsingleFile in TopLevelFiles)
                    {
                        try
                        {
                            string destName = Path.Combine(this.PreferredRootService.ClientFolder, Path.GetFileName(fsingleFile.FullName));
                            if (this.PreferredRootService.ClientFolderExists)
                            {
                                if (File.Exists(destName))
                                {
                                    File.Delete(destName);
                                }
                                File.Move(fsingleFile.FullName, destName);
                            }
                        }
                        catch
                        {
                        }
                        Thread.Sleep(10);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtils.Error(ex.Message, ex);
            }
            finally
            {
                this.tmrRootWatcher.Start();
            }
        }