当前位置: 首页>>代码示例>>C#>>正文


C# System.Diagnostics.Process.Dispose方法代码示例

本文整理汇总了C#中System.Diagnostics.Process.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.Dispose方法的具体用法?C# System.Diagnostics.Process.Dispose怎么用?C# System.Diagnostics.Process.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.Process的用法示例。


在下文中一共展示了System.Diagnostics.Process.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CatchImg

 /// <summary>
 /// 生成FLV视频的缩略图
 /// </summary>
 /// <param name="vFileName">视频文件地址</param>
 /// <param name="FlvImgSize">宽和高参数,如:240*180</param>
 /// <returns></returns>
 public static string CatchImg(string vFileName, string FlvImgSize, string Second)
 {
     if (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName)))
         return "";
     try
     {
         string flv_img_p = vFileName.Substring(0, vFileName.Length - 4) + "_thumbs.jpg";
         string Command = " -i \"" + HttpContext.Current.Server.MapPath(vFileName) + "\" -y -f image2 -ss " + Second + " -t 0.1 -s " + FlvImgSize + " \"" + HttpContext.Current.Server.MapPath(flv_img_p) + "\"";
         System.Diagnostics.Process p = new System.Diagnostics.Process();
         p.StartInfo.FileName = @"ffmpeg.exe";
         p.StartInfo.Arguments = Command;
         p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
         p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/bin/tools/");
         //不创建进程窗口
         p.StartInfo.CreateNoWindow = true;
         p.Start();//启动线程
         p.WaitForExit();//等待完成
         p.Close();//关闭进程
         p.Dispose();//释放资源
         System.Threading.Thread.Sleep(4000);
         //注意:图片截取成功后,数据由内存缓存写到磁盘需要时间较长,大概在3,4秒甚至更长;
         if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(flv_img_p)))
         {
             return flv_img_p;
         }
         return "";
     }
     catch
     {
         return "";
     }
 }
开发者ID:WZDotCMS,项目名称:WZDotCMS,代码行数:38,代码来源:ffmpegHelp.cs

示例2: PDF2SWF

 /// <summary>
 /// PDF格式转为SWF
 /// </summary>
 /// <param name="pdfPath">PDF文件地址</param>
 /// <param name="swfPath">生成后的SWF文件地址</param>
 /// <param name="beginpage">转换开始页</param>
 /// <param name="endpage">转换结束页</param>
 private static bool PDF2SWF(string pdfPath, string swfPath, int beginpage, int endpage, int photoQuality)
 {
     string exe = HttpContext.Current.Server.MapPath("~/Bin/tools/pdf2swf-0.9.1.exe");
     pdfPath = HttpContext.Current.Server.MapPath(pdfPath);
     swfPath = HttpContext.Current.Server.MapPath(swfPath);
     if (!System.IO.File.Exists(exe) || !System.IO.File.Exists(pdfPath) || System.IO.File.Exists(swfPath))
     {
         return false;
     }
     StringBuilder sb = new StringBuilder();
     sb.Append(" \"" + pdfPath + "\"");
     sb.Append(" -o \"" + swfPath + "\"");
     sb.Append(" -s flashversion=9");
     if (endpage > GetPageCount(pdfPath)) endpage = GetPageCount(pdfPath);
     sb.Append(" -p " + "\"" + beginpage + "" + "-" + endpage + "\"");
     sb.Append(" -j " + photoQuality);
     string Command = sb.ToString();
     System.Diagnostics.Process p = new System.Diagnostics.Process();
     p.StartInfo.FileName = exe;
     p.StartInfo.Arguments = Command;
     p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Bin/");
     p.StartInfo.UseShellExecute = false;
     p.StartInfo.RedirectStandardError = true;
     p.StartInfo.CreateNoWindow = false;
     p.Start();
     p.BeginErrorReadLine();
     p.WaitForExit();
     p.Close();
     p.Dispose();
     return true;
 }
开发者ID:lamp525,项目名称:DotNet,代码行数:38,代码来源:PSD2swfHelper.cs

示例3: FileCrypt

 /// <summary>
 /// 文件加解密
 /// </summary>
 /// <param name="oFileName">原文件地址</param>
 /// <param name="EncodeOrDecode">加密或解密参数,如:-d、-f</param>
 /// <param name="Password">密码</param>
 /// <returns></returns>
 public static bool FileCrypt(string oFileName, string EncodeOrDecode, string Password)
 {
     string jpfile = HttpContext.Current.Server.MapPath("~/Bin/tools/jpfile.exe");
     if ((!System.IO.File.Exists(jpfile)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(oFileName))))
     {
         return false;
     }
     oFileName = HttpContext.Current.Server.MapPath(oFileName);
     string Command = EncodeOrDecode + " \"" + oFileName + "\" \"" + Password + "\"";
     System.Diagnostics.Process p = new System.Diagnostics.Process();
     p.StartInfo.FileName = jpfile;
     p.StartInfo.Arguments = Command;
     p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Bin/");
     p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序 启动 线程
     //p.StartInfo.RedirectStandardInput = true;
     //p.StartInfo.RedirectStandardOutput = true;
     p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中(这个一定要注意,jpfile的所有输出信息,都为错误输出流,用 StandardOutput是捕获不到任何消息的...
     p.StartInfo.CreateNoWindow = false;//不创建进程窗口
     p.Start();//启动线程
     p.BeginErrorReadLine();//开始异步读取
     p.WaitForExit();//等待完成
     //p.StandardError.ReadToEnd();//开始同步读取
     p.Close();//关闭进程
     p.Dispose();//释放资源
     return true;
 }
开发者ID:WZDotCMS,项目名称:WZDotCMS,代码行数:33,代码来源:jpfileHelp.cs

示例4: ConvertFlv

 /// <summary>
 /// 视频格式转为Flv
 /// </summary>
 /// <param name="vFileName">原视频文件地址</param>
 /// <param name="ExportName">生成后的Flv文件地址</param>
 public bool ConvertFlv(string vFileName, string ExportName)
 {
     if ((!System.IO.File.Exists(ffmpegtool)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName))))
     {
         return false;
     }
     vFileName = HttpContext.Current.Server.MapPath(vFileName);
     ExportName = HttpContext.Current.Server.MapPath(ExportName);
     string Command = " -i \"" + vFileName + "\" -y -ab 32 -ar 22050 -b 800000 -s  480*360 \"" + ExportName + "\""; //Flv格式     
     System.Diagnostics.Process p = new System.Diagnostics.Process();
     p.StartInfo.FileName = ffmpegtool;
     p.StartInfo.Arguments = Command;
     p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/tools/");
     p.StartInfo.UseShellExecute = false;
     p.StartInfo.RedirectStandardInput = true;
     p.StartInfo.RedirectStandardOutput = true;
     p.StartInfo.RedirectStandardError = true;
     p.StartInfo.CreateNoWindow = false;
     p.Start();
     p.BeginErrorReadLine();
     p.WaitForExit();
     p.Close();
     p.Dispose();
     return true;
 }
开发者ID:Jsiegelion,项目名称:ExaminationOnline,代码行数:30,代码来源:VideoConvert.cs

示例5: linkLabel1_LinkClicked

 private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     System.Diagnostics.Process p = new System.Diagnostics.Process();
     p.StartInfo.CreateNoWindow = false;
     p.StartInfo.UseShellExecute = true;
     p.StartInfo.FileName = "iexplore";
     p.StartInfo.Arguments = "http://www.chuiniudi.cn";
     p.Start();
     p.Dispose();
 }
开发者ID:TheLegion96,项目名称:fightthelandlord,代码行数:10,代码来源:About.cs

示例6: ListFiles

        /// <summary> 
        /// 递归列举出指定目录的所有文件         /// </summary> 
        public static void ListFiles(FileSystemInfo info, string _rex)
        {
            if (!info.Exists) return;
            DirectoryInfo dir = info as DirectoryInfo;                 //不是目录
            if (dir == null) return;
            string _filePath = string.Empty;
            Dictionary<DateTime, string> _fs = new Dictionary<DateTime, string>();
            FileSystemInfo[] files = dir.GetFileSystemInfos(_rex + "_*.rar");
            for (int i = 0; i < files.Length; i++)
            {
                FileInfo f = files[i] as FileInfo;                     //是文件
                if (f != null)
                {
                    //string _fn = f.Name;
                    //Regex r = new Regex("epis_.*_");
                    //string _t = r.Replace(_fn, "").Replace(".rar", "");

                    DateTime _dt = f.CreationTimeUtc;
                    _fs.Add(_dt, f.FullName);
                }
            }
            Dictionary<DateTime, string> dic1 = _fs.OrderBy(o => o.Key).ToDictionary(o => o.Key, p => p.Value);
            _filePath = dic1[dic1.Keys.Max()];
            FileInfo file = new FileInfo(_filePath);
            if (file != null)
            {
                AddFileSecurity(file.FullName, "Everyone", FileSystemRights.FullControl, AccessControlType.Allow);
                Config.DatabaseFile = file.FullName;

                System.Diagnostics.Process p = new System.Diagnostics.Process();

                try
                {
                    System.Diagnostics.ProcessStartInfo startinfo = new System.Diagnostics.ProcessStartInfo();
                    startinfo.FileName = @"WinRAR.exe";//需要启动的程序名
                    string rarPath = file.Directory.FullName;
                    startinfo.Arguments = string.Format("x -p0x00000000025203a0 {0} {1}", file.FullName, rarPath);//启动参数
                                                                                                                  //设置命令参数
                                                                                                                  //startinfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;  //隐藏 WinRAR 窗口
                    p.StartInfo = startinfo;
                    p.Start();//启动
                    p.WaitForExit(); //无限期等待进程 winrar.exe 退出
                }
                catch (Exception ex) { throw ex; }
                finally
                {
                    p.Dispose();
                    p.Close();
                }
            }
        }
开发者ID:junenigma,项目名称:uhvclient,代码行数:53,代码来源:FileUtils.cs

示例7: ExecuteCommand

        /// <summary>
        /// Execute a Commad
        /// </summary>
        public List<string> ExecuteCommand(string cmd, string args)
        {
            answer.Clear();
            System.Diagnostics.Process process = null;
            System.Diagnostics.ProcessStartInfo processStartInfo;
            processStartInfo = new System.Diagnostics.ProcessStartInfo();

            processStartInfo.FileName = cmd;
            if (System.Environment.OSVersion.Version.Major >= 6)  // Windows Vista or higher
            {
                processStartInfo.Verb = "runas";
            }

            processStartInfo.Arguments = args;
            processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
            processStartInfo.UseShellExecute = false;
            processStartInfo.RedirectStandardOutput = true;
            processStartInfo.RedirectStandardError = true;
            processStartInfo.RedirectStandardInput = true;

            process = new System.Diagnostics.Process();
            process.StartInfo = processStartInfo;
            process.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(process_OutputDataReceived);

            try
            {
                process.Start();

                StreamWriter streamWriter = process.StandardInput;
                process.BeginOutputReadLine();
                streamWriter.Close();
                process.WaitForExit();

                string error = process.StandardError.ReadToEnd();
                if (!error.Equals(""))
                {
                    answer.Add("Errors Found: " + error);
                }
            }
            catch (Exception ex)
            {
                answer.Add("Exception: " + ex.Message);
            }

            if (process != null)
            {
                process.Dispose();
            }

            return answer;
        }
开发者ID:jmecosta,项目名称:VSSonarAddin,代码行数:54,代码来源:CommandExecution.cs

示例8: StartFBIP

        public void StartFBIP()
        {
            /* Pre:  ForceBindIP not already installed
              *
              * Post: Launch ForceBindIP Installer*/

            System.Diagnostics.Process startFBIP = new System.Diagnostics.Process();
            startFBIP.EnableRaisingEvents = false;
            startFBIP.StartInfo.FileName = "ForceBindIP-1.2a-Setup.exe";
            try
            {
                startFBIP.Start();
                startFBIP.WaitForExit();
            }
            catch
            {
            }
            startFBIP.Close();
            startFBIP.Dispose();
        }
开发者ID:ssmereka,项目名称:Warp-Gate,代码行数:20,代码来源:Launcher.cs

示例9: StartHamachi

        public void StartHamachi()
        {
            /* Pre: Hamachi not already installed
              *
              * Post: Launch Hamachi installer */
            System.Diagnostics.Process startHamachi = new System.Diagnostics.Process();
            startHamachi.EnableRaisingEvents = false;
            startHamachi.StartInfo.FileName = "hamachi.msi";
            try
            {
                startHamachi.Start();
                startHamachi.WaitForExit();
            }
            catch
            {
            }

            startHamachi.Close();
            startHamachi.Dispose();
        }
开发者ID:ssmereka,项目名称:Warp-Gate,代码行数:20,代码来源:Launcher.cs

示例10: CatchImg

 /// <summary>
 /// 生成FLV视频的缩略图
 /// </summary>
 /// <param name="vFileName">视频文件地址</param>
 /// <param name="FlvImgSize">宽和高参数,如:240*180</param>
 /// <returns></returns>
 public static string CatchImg(string vFileName, string FlvImgSize)
 {
     string ffmpeg = HttpContext.Current.Server.MapPath("~/tools/ffmpeg.exe");
     if ((!System.IO.File.Exists(ffmpeg)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName))))
         return "";
     try
     {
         string flv_img_p = vFileName.Substring(0, vFileName.Length - 4) + ".jpg";
         string Command = " -i \"" + HttpContext.Current.Server.MapPath(vFileName) + "\" -y -f image2 -t 0.1 -s " + FlvImgSize + " \"" + HttpContext.Current.Server.MapPath(flv_img_p) + "\"";
         System.Diagnostics.Process p = new System.Diagnostics.Process();
         p.StartInfo.FileName = ffmpeg;
         p.StartInfo.Arguments = Command;
         p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
         try
         {
             p.Start();
         }
         catch
         {
             return "";
         }
         finally
         {
             p.Close();
             p.Dispose();
         }
         System.Threading.Thread.Sleep(4000);
         //注意:图片截取成功后,数据由内存缓存写到磁盘需要时间较长,大概在3,4秒甚至更长;
         if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(flv_img_p)))
         {
             return flv_img_p;
         }
         return "";
     }
     catch
     {
         return "";
     }
 }
开发者ID:huaminglee,项目名称:Cooperative--Office-Automation-System,代码行数:45,代码来源:ffmpegHelp.cs

示例11: StartSC

 public void StartSC()
 {
     System.Diagnostics.Process startSC = new System.Diagnostics.Process();
     try
     {
         startSC.EnableRaisingEvents = false;
         startSC.StartInfo.CreateNoWindow = true;
         startSC.StartInfo.Arguments = "/c " + Argument;
         startSC.StartInfo.FileName = "CMD.exe";
         System.Threading.Thread.Sleep(1000);
         startSC.Start();
         startSC.WaitForExit();
     }
     catch
     {
         //Inform main class
         //startSC.Close();
        // startSC.Dispose();
     }
     startSC.Close();
     startSC.Dispose();
 }
开发者ID:ssmereka,项目名称:Warp-Gate,代码行数:22,代码来源:Launcher.cs

示例12: CatchImg

        /// <summary>
        /// ����Flv��Ƶ������ͼ
        /// </summary>
        /// <param name="vFileName">��Ƶ�ļ���ַ</param>
        public string CatchImg(string vFileName)
        {
            if ((!System.IO.File.Exists(ffmpegtool)) || (!System.IO.File.Exists(HttpContext.Current.Server.MapPath(vFileName)))) return "";
            try
            {
                string flv_img_p = vFileName.Substring(0, vFileName.Length - 4) + ".jpg";
                string Command = " -i " + HttpContext.Current.Server.MapPath(vFileName) + " -y -f image2 -t 0.1 -s " + sizeOfImg + " " + HttpContext.Current.Server.MapPath(flv_img_p);
                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.StartInfo.FileName = ffmpegtool;
                p.StartInfo.Arguments = Command;
                p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                try
                {
                    p.Start();
                }
                catch
                {
                    return "";
                }
                finally
                {
                    p.Close();
                    p.Dispose();
                }
                System.Threading.Thread.Sleep(4000);

                //ע��:ͼƬ��ȡ�ɹ���,�������ڴ滺��д��������Ҫʱ��ϳ�,�����3,4����������;
                if (System.IO.File.Exists(HttpContext.Current.Server.MapPath(flv_img_p)))
                {
                    return flv_img_p;
                }
                return "";
            }
            catch
            {
                return "";
            }
        }
开发者ID:GitWPeng,项目名称:Helper,代码行数:42,代码来源:VideoHelper.cs

示例13: Convert2Flv

 /// <summary>
 /// 视频格式转为Flv
 /// </summary>
 /// <param name="vFileName">原视频文件地址</param>
 /// <param name="WidthAndHeight">宽和高参数,如:480*360</param>
 /// <param name="ExportName">生成后的FLV文件地址</param>
 /// <returns></returns>
 public static bool Convert2Flv(string vFileName, string WidthAndHeight, string ExportName)
 {
     try
     {
         vFileName = HttpContext.Current.Server.MapPath(vFileName);
         ExportName = HttpContext.Current.Server.MapPath(ExportName);
         string Command = " -i \"" + vFileName + "\" -y -ab 32 -ar 22050 -b 800000 -s " + WidthAndHeight + " \"" + ExportName + "\""; //Flv格式
         System.Diagnostics.Process p = new System.Diagnostics.Process();
         p.StartInfo.FileName = @"ffmpeg.exe";
         p.StartInfo.Arguments = Command;
         p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/bin/tools/");
         #region 方法一
         //p.StartInfo.UseShellExecute = false;//不使用操作系统外壳程序 启动 线程
         //p.StartInfo.RedirectStandardError = true;//把外部程序错误输出写到StandardError流中(这个一定要注意,FFMPEG的所有输出信息,都为错误输出流,用 StandardOutput是捕获不到任何消息的...
         //p.StartInfo.CreateNoWindow = false;//不创建进程窗口
         //p.Start();//启动线程
         //p.BeginErrorReadLine();//开始异步读取
         //p.WaitForExit();//等待完成
         //p.Close();//关闭进程
         //p.Dispose();//释放资源
         #endregion
         #region 方法二
         p.StartInfo.CreateNoWindow = true;
         p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
         p.Start();//启动线程
         p.WaitForExit();//等待完成
         p.Close();//关闭进程
         p.Dispose();//释放资源
         #endregion
     }
     catch (System.Exception e)
     {
         throw e;
     }
     return true;
 }
开发者ID:WZDotCMS,项目名称:WZDotCMS,代码行数:43,代码来源:ffmpegHelp.cs

示例14: mnuNewInstance_Click

        void mnuNewInstance_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process instance = null;

            try
            {
                Program.CursorWait();
                instance = new System.Diagnostics.Process();
                instance.StartInfo.FileName = Application.ExecutablePath;
                instance.StartInfo.Arguments = "nosplash";
                instance.Start();
            }
            catch (Exception ex)
            {
                Program.CursorDefault();
                Program.ErrMsgBox(ex.Message);
            }
            finally
            {
                if (instance != null)
                    instance.Dispose();

                Program.CursorDefault();
            }
        }
开发者ID:Veivan,项目名称:GanttDll,代码行数:25,代码来源:frmMain.cs

示例15: OnFileRequested

 // Somebody asked for ping.kat.
 public void OnFileRequested(HttpRequest request, IDirectory directory)
 {
     request.Response.ResponseContent = new MemoryStream();
     StreamWriter textWriter = new StreamWriter(request.Response.ResponseContent);
     try
     {
         // Loop through each user and check if they're connected. If so,
         // increment the connected count.
         int usercount = 0;
         foreach (KeyValuePair<Guid,User> pair in users)
         {
             User user = pair.Value;
             if (user.Client != null && user.Client.Network.Connected)
             {
                 ++usercount;
             }
         }
         // Write out the connected count.
         textWriter.WriteLine(usercount);
         // Work out and write the time running in seconds.
         TimeSpan span = DateTime.UtcNow.Subtract(started);
         textWriter.WriteLine(span.TotalSeconds);
         try
         {
             // This is .NET-speak for "print exec('free')".
             // It's really rather complicated.
             // (N.B. "free" spits out how much memory you're using)
             System.Diagnostics.Process process = new System.Diagnostics.Process();
             process.StartInfo.UseShellExecute = false;
             process.StartInfo.RedirectStandardOutput = true;
             process.StartInfo.FileName = "free";
             process.Start();
             textWriter.Write(process.StandardOutput.ReadToEnd());
             process.WaitForExit();
             process.Dispose();
         }
         catch
         {
             textWriter.Write("Unable to get memory info.");
         }
     }
     catch (Exception exception)
     {
         this.contenttype = "text/plain";
         textWriter.WriteLine(exception.Message);
     }
     textWriter.Flush();
 }
开发者ID:cfire24,项目名称:ajaxlife,代码行数:49,代码来源:BasicStats.cs


注:本文中的System.Diagnostics.Process.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。