示例#1
0
            /// <summary>
            /// 启动word进程
            /// </summary>
            public int startUpWordProcess()
            {
                int retVal = 0;
                ControlWordPanelService controlWordPanelService = new ControlWordPanelService();

                controlWordPanelService.updateDisplayFlagToShow();
                Thread thread = new Thread(new ThreadStart(delegate()
                {
                    System.Windows.Forms.OpenFileDialog file = new System.Windows.Forms.OpenFileDialog();
                    System.Windows.Forms.DialogResult result = file.ShowDialog();
                    if (System.Windows.Forms.DialogResult.OK == result)
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.FileName         = "WINWORD.EXE";
                        startInfo.Arguments        = file.FileName;
                        try
                        {
                            Process.Start(startInfo);
                            retVal = 1;
                        }
                        catch (Exception e)
                        {
                            MSMessageBox.ShowModal(MSMessageBox.MSMessageBoxButton.OK, "错误", "Cannot start Microsoft Word, please make sure it is installed");
                        }
                    }
                }));

                thread.TrySetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();
                return(retVal);
            }
示例#2
0
            /// <summary>
            /// 下载并打开word
            /// <param name="wordPic">word文件路径</param>
            /// <param name="wordName">word文件名</param>
            /// </summary>
            public int downloadAndOpenFile(string wordPic, string wordName)
            {
                System.Net.WebClient myWebClient = new System.Net.WebClient();
                string docDirectory = AppDomain.CurrentDomain.BaseDirectory + "docTempDirectory\\";

                if (false == System.IO.Directory.Exists(docDirectory))
                {
                    System.IO.Directory.CreateDirectory(docDirectory);
                }
                myWebClient.DownloadFile(MSConfig.host_lw_file_server_download + wordPic + "&name=" + wordName, docDirectory + wordName);
                ControlWordPanelService controlWordPanelService = new ControlWordPanelService();

                controlWordPanelService.updateDisplayFlagToShow();
                Thread thread = new Thread(new ThreadStart(delegate()
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo();
                    startInfo.FileName         = "WINWORD.EXE";
                    startInfo.Arguments        = docDirectory + wordName;
                    try
                    {
                        Process.Start(startInfo);
                    }
                    catch (Exception e)
                    {
                        MSMessageBox.ShowModal(MSMessageBox.MSMessageBoxButton.OK, "错误", "Cannot start Microsoft Word, please make sure it is installed");
                    }
                }));

                thread.TrySetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();

                return(1);
            }