コード例 #1
0
        private void SyncPromoteButton_Click(object sender, EventArgs e)
        {
            string toolsPath = Path.Combine(MOG_ControllerProject.GetProjectPath(), "Tools");

            ComboBoxItem filter = SyncFilterComboBox.SelectedItem as ComboBoxItem;

            if (filter != null)
            {
                string targetFilterName = "";
                string filterFileName   = filter.FullPath;
                if (filterFileName.Contains(MOG_ControllerProject.GetUserPath()))
                {
                    targetFilterName = filterFileName.Replace(MOG_ControllerProject.GetUser().GetUserToolsPath(), toolsPath);
                }
                else
                {
                    // This is a project tool and should be demoted
                    targetFilterName = filterFileName.Replace(toolsPath, MOG_ControllerProject.GetUser().GetUserToolsPath());
                }

                // This is a user tool and should be promoted
                if (DosUtils.FileCopyFast(filterFileName, targetFilterName, true))
                {
                    if (DosUtils.FileDeleteFast(filterFileName))
                    {
                        UpdateFilterDropDown(Path.GetFileNameWithoutExtension(targetFilterName));
                        UpdatePromoteButton();
                    }
                }
            }
        }
コード例 #2
0
ファイル: UserTrashBin.cs プロジェクト: MOGwareSupport/MOG
        private ArrayList DeleteFilesByAge(string path, long interval, bool recurse)
        {
            ArrayList filelist = new ArrayList();

            DirectoryInfo dInfo = new DirectoryInfo(path);

            foreach (FileInfo fInfo in dInfo.GetFiles())
            {
                long difference = DateTime.Now.Ticks - fInfo.LastWriteTime.Ticks;
                if (difference >= interval)
                {
                    try
                    {
                        if (DosUtils.FileDeleteFast(fInfo.FullName))
                        {
                            filelist.Add("Deleted " + fInfo.FullName);
                            DosUtils.DirectoryDeleteEmptyParentsFast(fInfo.DirectoryName, true);
                        }
                        else
                        {
                            filelist.Add("Couldn't delete " + fInfo.FullName);
                        }
                    }
                    catch
                    {
                        filelist.Add("Couldn't delete " + fInfo.FullName);
                        continue;
                    }
                }
            }

            if (recurse)
            {
                foreach (string dirname in Directory.GetDirectories(path))
                {
                    filelist.AddRange(DeleteFilesByAge(dirname, interval, true));
                }
            }

            return(filelist);
        }