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.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace ExeFileStart
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//调用exe文件
//System.Diagnostics.Process pro = new System.Diagnostics.Process();
//System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//startInfo.Arguments = "username:admin|password:110";
//startInfo.FileName = @"D:\Progress\Progress\bin\Debug\Progress.exe";
//pro.StartInfo = startInfo;
//pro.Start();
System.Diagnostics.Process.Start(@"D:\项目文件夹\项目产品\复件 (2) 图侦系统2012-12-10\CollectEvidence\bin\Debug\CollectEvidence.exe", "username:admin|password:110");
string[] strs = Environment.GetCommandLineArgs();//获取调用exe中传来的参数
}
BackgroundWorker worker = null;
private void Form1_Load(object sender, EventArgs e)
{
if (worker == null)
{
worker = new BackgroundWorker();
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
}
worker.RunWorkerAsync(@"D:\项目文件夹\新建 文本文档.txt");
}
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
textBox1.Text = e.Result as string;
}
void worker_DoWork(object sender, DoWorkEventArgs e)
{
FileStream stream = File.Open(e.Argument as string,FileMode.Open);
StreamReader sr = new StreamReader(stream,Encoding.Default);
e.Result=sr.ReadToEnd();
stream.Close();
sr.Close();
}
}
}