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

        DirectoryTool.FullDeleteDirectories(dirPath);
    }
예제 #2
0
 private void DeleteFiles(File_DownloadItemViewModel fileItem)
 {
     if (File.Exists(fileItem.StorageFilePath))
     {
         File.Delete(fileItem.StorageFilePath);
     }
     DirectoryTool.FullDeleteDirectories(fileItem.UnZipFilePath);
 }
예제 #3
0
        private void DeleteFiles(File_DownloadItemViewModel fileItem)
        {
            // 解壓縮失敗,要記得把原始檔案和解壓縮資料夾一起刪除
            if (File.Exists(fileItem.StorageFilePath) == true)
            {
                File.Delete(fileItem.StorageFilePath);
            }

            DirectoryTool.FullDeleteDirectories(fileItem.UnZipFilePath);
        }
예제 #4
0
        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 %";
            }
        }
        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 %";
            }
        }