资料来源:网络整理
时间:2023/2/14 0:48:49 共计:3619 浏览
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
//使用C#调用BAT文件实现垃圾清理并显示清理结果
//作者:秦元培
//时间:2012年1月12日
//不足:占用线程太久,界面会卡死,出来的信息无法分辨是已经删除了的还是拒绝访问了的
namespace AutoCleanner
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process pro = new Process();
pro.StartInfo.FileName = "autocleaner.bat";
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardInput = true;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.RedirectStandardError = true;
pro.StartInfo.CreateNoWindow = true;
pro.Start();
while (pro.WaitForExit(0)==false)
{
textBox1.AppendText(pro.StandardOutput.ReadLine() + "\r\n");
}
pro.WaitForExit();
}
}
}
代码比较简单,无聊时写着玩的,呵呵!

版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。