예제 #1
0
        //private ExeToWinForm form;

        /// <summary>
        /// 打开文件
        /// </summary>
        private void Btn_OpenFile_Click(object sender, EventArgs e)
        {
            object[] rootId = SQLiteHelper.ExecuteSingleColumnQuery($"SELECT bfi_id FROM backup_files_info WHERE bfi_code = '-1'");
            if (rootId.Length > 0)
            {
                Frm_AddFile_FileSelect frm = new Frm_AddFile_FileSelect(rootId);
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    string fullPath = frm.SelectedFileName;
                    if (File.Exists(fullPath))
                    {
                        string savePath = Application.StartupPath + @"\TempBackupFolder\";
                        if (!Directory.Exists(savePath))
                        {
                            Directory.CreateDirectory(savePath);
                        }
                        string filePath = savePath + new FileInfo(fullPath).Name;
                        File.Copy(fullPath, filePath, true);
                        txt_link.Text = fullPath;
                        txt_link.Tag  = frm.SelectedFileId;

                        //尝试获取页数
                        try
                        {
                            string format = Path.GetExtension(fullPath).ToLower();
                            if (format.Contains("doc") || format.Contains("docx"))
                            {
                                num_page.Value = (int)GetFilePageCount.GetFilePageCountInstince().GetWordPageCount(fullPath);
                            }
                            else if (format.Contains("pdf"))
                            {
                                num_page.Value = (int)GetFilePageCount.GetFilePageCountInstince().GetPDFPageCount(fullPath);
                            }
                        } catch (Exception) { }

                        if (MessageBox.Show("已从服务器拷贝文件到本地,是否现在打开?", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            System.Diagnostics.Process.Start("Explorer.exe", filePath);
                            //if(form != null)
                            //    form.Stop();
                            //WindowState = FormWindowState.Maximized;
                            //pal_ShowData.Visible = true;
                            //pal_ShowData.Controls.Clear();

                            //form = new ExeToWinForm(pal_ShowData, string.Empty);
                            //form.Start(fullPath);
                        }
                    }
                    else
                    {
                        MessageBox.Show("服务器不存在此文件。", "打开失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }
            }
            else
            {
                MessageBox.Show("当前专项尚未导入数据。", "操作失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
 public static GetFilePageCount GetFilePageCountInstince()
 {
     if (_getFilePageCount == null)
     {
         _getFilePageCount = new GetFilePageCount();
     }
     return(_getFilePageCount);
 }