public static void DeleteDirectory(string dirName)
    {
        string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
        string dirPath    = Path.Combine(folderPath, "Programs", dirName);

        DirectoryTool.FullDeleteDirectories(dirPath);
    }
Exemple #2
0
 static void CopyAssetPath()
 {
     //生成资源根路径
     DirectoryTool.CreatIfNotExists(Application.dataPath + FrameWorkConst.FastBundleResFolder);
     DirectoryTool.CreatIfNotExists(Application.dataPath + FrameWorkConst.FastBundleResConfigFolder);
     AssetDatabase.Refresh();
 }
Exemple #3
0
 private void DeleteFiles(File_DownloadItemViewModel fileItem)
 {
     if (File.Exists(fileItem.StorageFilePath))
     {
         File.Delete(fileItem.StorageFilePath);
     }
     DirectoryTool.FullDeleteDirectories(fileItem.UnZipFilePath);
 }
Exemple #4
0
        /// <summary>
        /// 删除场景对象(数据库记录和服务器文件夹)
        /// </summary>
        /// <param name="scene">要删除的场景对象</param>
        public static void DeleteScene(Scene scene)
        {
            IEnumerable <string> serverFiles = ErpService.DressManagement.GetScenePhotoFiles(scene);
            IEnumerable <string> sceneDirs   = DirectoryTool.GetDistinctDirectories(serverFiles);

            ErpService.DressManagement.DeleteScene(scene);
            DirectoryTool.DeleteDirectories(sceneDirs);
        }
        private void DeleteFiles(File_DownloadItemViewModel fileItem)
        {
            // 解壓縮失敗,要記得把原始檔案和解壓縮資料夾一起刪除
            if (File.Exists(fileItem.StorageFilePath) == true)
            {
                File.Delete(fileItem.StorageFilePath);
            }

            DirectoryTool.FullDeleteDirectories(fileItem.UnZipFilePath);
        }
        public void SetPath(string urlpath, string ext)
        {
            List <String> filenames = DirectoryTool.GetAllFileName(urlpath, ext);

            foreach (String file in filenames)
            {
                comboBox1.Items.Add(file);
            }
            Tag = urlpath;
        }
 private static void _003CCopyLog_003Eb__0()
 {
     try
     {
         string   baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
         string[] directories   = Directory.GetDirectories(Path.Combine(baseDirectory, "Logs"));
         if (CS_0024_003C_003E9__CachedAnonymousMethodDelegate3 == null)
         {
             CS_0024_003C_003E9__CachedAnonymousMethodDelegate3 = new Func <string, string>(_003CCopyLog_003Eb__1);
         }
         string sourcePath = Enumerable.First(Enumerable.OrderByDescending(directories, CS_0024_003C_003E9__CachedAnonymousMethodDelegate3));
         DirectoryTool.FullCopyDirectories(sourcePath, ClickOnceTool.GetFilePath());
     }
     catch (Exception ex)
     {
         LogTool.Debug(ex);
     }
 }
Exemple #8
0
 private void CopyLog()
 {
     if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
     {
         Task.Factory.StartNew(() =>
         {
             try
             {
                 string AppDir = AppDomain.CurrentDomain.BaseDirectory;
                 string dir    = Directory.GetDirectories(System.IO.Path.Combine(AppDir, "Logs")).OrderByDescending(f => f).First();
                 DirectoryTool.FullCopyDirectories(dir, ClickOnceTool.GetFilePath());
             }
             catch (Exception ex)
             {
                 LogTool.Debug(ex);
             }
         });
     }
 }
        private void btnDelete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            string QuestSring = "您確定要刪除檔案?";

            // userMeeting.isDownload + userMeeting.isBrowserd
            switch (meetingRoomButtonType)
            {
            case MeetingRoomButtonType.NN:
                break;

            case MeetingRoomButtonType.YY:
                break;

            case MeetingRoomButtonType.OY:
                QuestSring = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String);
                break;

            case MeetingRoomButtonType.YO:
                QuestSring = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", PaperLess_Emeeting.Properties.Settings.Default.CourseOrMeeting_String);
                break;
            }

            MessageBoxResult result = MessageBox.Show(QuestSring, "系統訊息", MessageBoxButton.YesNo);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }

            MouseTool.ShowLoading();
            bool HasDelete = false;

            try
            {
                //找出資料庫所有的檔案並且重置和刪除。
                // 多少檔案完成

                // 抓取檔案路徑
                DataTable dt = MSCE.GetDataTable(@"select ID,StorageFileName from FileRow where UserID =@1 and MeetingID=@2 and DownloadBytes!=0 and DownloadBytes >= TotalBytes;"
                                                 , UserID, userMeeting.ID);

                // 多少檔案要被刪除
                foreach (DataRow dr in dt.Rows)
                {
                    string filePath          = ClickOnceTool.GetFilePath();
                    string StorageFileFolder = PaperLess_Emeeting.Properties.Settings.Default.File_StorageFileFolder;
                    string UnZipFileFolder   = PaperLess_Emeeting.Properties.Settings.Default.File_UnZipFileFolder;
                    string StorageFilePath   = filePath + "\\" + StorageFileFolder + "\\" + dr["StorageFileName"].ToString();
                    string UnZipFilePath     = filePath + "\\" + UnZipFileFolder + "\\" + UserID + "\\" + userMeeting.ID + "\\" + dr["ID"].ToString();

                    if (File.Exists(StorageFilePath) == true)
                    {
                        File.Delete(StorageFilePath);
                    }

                    DirectoryTool.FullDeleteDirectories(UnZipFilePath);
                }

                string SQL     = @"update FileRow set DownloadBytes=0,TotalBytes=0,FinishedFileVersion=0 where UserID =@1 and MeetingID=@2 ";
                int    success = MSCE.ExecuteNonQuery(SQL
                                                      , UserID, userMeeting.ID);

                if (success < 1)
                {
                    LogTool.Debug(new Exception(@"DB失敗: " + SQL));
                }
                else
                {
                    HasDelete = true;
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
            MouseTool.ShowArrow();
            if (HasDelete == false)
            {
                AutoClosingMessageBox.Show("刪除失敗");
            }
            else
            {
                // userMeeting.isDownload + userMeeting.isBrowserd
                //switch (meetingRoomButtonType)
                //{
                //    case MeetingRoomButtonType.NN:
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            pb.Value = pb.Minimum;
                //        break;
                //    case MeetingRoomButtonType.YY:
                //            // 一般都會顯示這個,除非下載瀏覽過期之類的
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            btnDownload.Visibility = Visibility.Visible;
                //            pb.Value = pb.Minimum;
                //        break;
                //    case MeetingRoomButtonType.OY:
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            btnDownloadForbidden.Visibility = Visibility.Visible;
                //            pb.Value = pb.Minimum;
                //        break;
                //    case MeetingRoomButtonType.YO:
                //            btnDelete.Visibility = Visibility.Collapsed;
                //            btnRead2Forbidden.Visibility = Visibility.Visible;
                //            pb.Value = pb.Minimum;
                //        break;
                //}
                btnDelete.Visibility  = Visibility.Collapsed;
                btnRefresh.Visibility = Visibility.Visible;
                pb.Value        = pb.Minimum;
                txtPercent.Text = "0 %";
            }
        }
Exemple #10
0
        static void wrPublication(object sender, DoWorkEventArgs e)
        {
            var args = (object[])e.Argument;

            var worker  = (BackgroundWorker)sender;
            var cfg     = (publishConfig)args[1];
            var configs = (ConfigFilesCollection)args[0];
            var di      = new DirectoryInfo(cfg.DestinationPath);

            //verify before deleting if tabloid and config folder exist
            var subFolder = di.GetDirectories();

            if (subFolder.Length > 0)
            {
                if (!subFolder.Any(r => r.FullName.Equals(Path.Combine(di.FullName, "tabloid"), StringComparison.InvariantCultureIgnoreCase)) &&
                    !subFolder.Any(r => r.FullName.Equals(Path.Combine(di.FullName, "configs"), StringComparison.InvariantCultureIgnoreCase)))
                {//if exist warn user before deleting
                    if (MetroMessageBox.Show((IWin32Window)args[2], Properties.Resources.NotTabloidFolderConfirm, Properties.Resources.Information, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                        == DialogResult.No)
                    {
                        return;
                    }
                }
            }

            //delete file in selected folder
            worker.ReportProgress(0, new WaitingFormProperties(Properties.Resources.Publication, Properties.Resources.RemovingFolderFiles));
            foreach (FileInfo file in di.GetFiles())
            {
                if (!string.Equals(file.Name, "web.config", StringComparison.OrdinalIgnoreCase) || !cfg.KeepWebConfig)
                {
                    file.Delete();
                }
            }

            //delete unnecessary sub-folders in future folder
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                if (!string.Equals(dir.Name, "Uploads", StringComparison.OrdinalIgnoreCase) || !cfg.KeepUpload)
                {
                    if (!string.Equals(dir.Name, "Scripts", StringComparison.OrdinalIgnoreCase) || !cfg.KeepOpenJs)
                    {
                        if (!string.Equals(dir.Name, "images", StringComparison.OrdinalIgnoreCase) || !cfg.KeepImages)
                        {
                            if (!string.Equals(dir.Name, "Configs", StringComparison.OrdinalIgnoreCase) || !cfg.KeepOpenJs)
                            {
                                dir.Delete(true);
                            }
                        }
                    }
                }
            }

            worker.ReportProgress(0, new WaitingFormProperties(Properties.Resources.Publication, Properties.Resources.TabloidFileCopy));

            List <String> exclude = new List <String>();


            if (cfg.KeepWebConfig)
            {
                exclude.Add("Web.config");
            }

            try
            {
                DirectoryTool.Copy(@"sources\Tabloid\TabloidProject", cfg.DestinationPath, exclude.ToArray());
                DirectoryTool.Copy(@"sources\Tabloid\Tabloid", cfg.DestinationPath + @"\Tabloid");
                DirectoryTool.Copy(@"sources\Tabloid\Tabloid\bin", cfg.DestinationPath + @"\bin");
            }

            catch
            {
                MetroMessageBox.Show((IWin32Window)args[2], Properties.Resources.SourceFileCopyError, Properties.Resources.Erreur, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (!cfg.KeepWebConfig)
            {
                worker.ReportProgress(0, new WaitingFormProperties(Properties.Resources.Publication, Properties.Resources.CustomingConfig));
                ConnManager.personalizeDbProvider(cfg.DestinationPath + @"\web.config");
            }

            worker.ReportProgress(0, new WaitingFormProperties(Properties.Resources.Publication, Properties.Resources.Cleanning));
            var v = new DirectoryInfo(cfg.DestinationPath + @"\Tabloid\bin");

            v.Delete(true);

            worker.ReportProgress(0, new WaitingFormProperties(Properties.Resources.Publication, Properties.Resources.SavingConfig));
            configs.updateXML();
            configs.ChangeConfigFilesPath(cfg.DestinationPath);
            configs.SaveConfigFiles(false, (IWin32Window)args[2]);

            //if not exist create dir scripts and upload
            Directory.CreateDirectory(cfg.DestinationPath + @"\uploads");
            Directory.CreateDirectory(cfg.DestinationPath + @"\scripts");

            AddDirectorySecurity(cfg.DestinationPath + @"\uploads", "IIS_IUSRS", FileSystemRights.FullControl, AccessControlType.Allow);

            //set authentication mode
            AuthenticationHandler.Set(Program.AppSet.ModeAuthentification);
        }
        private void btnDelete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;
            string messageBoxText = "您確定要刪除檔案?";

            switch (meetingRoomButtonType)
            {
            case MeetingRoomButtonType.OY:
                messageBoxText = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", Settings.Default.CourseOrMeeting_String);
                break;

            case MeetingRoomButtonType.YO:
                messageBoxText = string.Format("{0}附件資料下載時間已過期,是否確認刪除?", Settings.Default.CourseOrMeeting_String);
                break;
            }
            MessageBoxResult messageBoxResult = MessageBox.Show(messageBoxText, "系統訊息", MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                MouseTool.ShowLoading();
                bool flag = false;
                try
                {
                    DataTable dataTable = MSCE.GetDataTable("select ID,StorageFileName from FileRow where UserID =@1 and MeetingID=@2 and DownloadBytes!=0 and DownloadBytes >= TotalBytes;", UserID, userMeeting.ID);
                    foreach (DataRow row in dataTable.Rows)
                    {
                        string filePath = ClickOnceTool.GetFilePath();
                        string file_StorageFileFolder = Settings.Default.File_StorageFileFolder;
                        string file_UnZipFileFolder   = Settings.Default.File_UnZipFileFolder;
                        string path    = filePath + "\\" + file_StorageFileFolder + "\\" + row["StorageFileName"].ToString();
                        string dirPath = filePath + "\\" + file_UnZipFileFolder + "\\" + UserID + "\\" + userMeeting.ID + "\\" + row["ID"].ToString();
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                        DirectoryTool.FullDeleteDirectories(dirPath);
                    }
                    string text = "update FileRow set DownloadBytes=0,TotalBytes=0,FinishedFileVersion=0 where UserID =@1 and MeetingID=@2 ";
                    int    num  = MSCE.ExecuteNonQuery(text, UserID, userMeeting.ID);
                    if (num < 1)
                    {
                        LogTool.Debug(new Exception("DB失敗: " + text));
                    }
                    else
                    {
                        flag = true;
                    }
                }
                catch (Exception ex)
                {
                    LogTool.Debug(ex);
                }
                MouseTool.ShowArrow();
                if (!flag)
                {
                    AutoClosingMessageBox.Show("刪除失敗");
                    return;
                }
                btnDelete.Visibility  = Visibility.Collapsed;
                btnRefresh.Visibility = Visibility.Visible;
                pb.Value        = pb.Minimum;
                txtPercent.Text = "0 %";
            }
        }