| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace CollectionTest
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.InitialDirectory = "c://";
- openFileDialog.Filter = "所有文件|*.*";
- openFileDialog.RestoreDirectory = true;
- openFileDialog.FilterIndex = 1;
- if (openFileDialog.ShowDialog() == DialogResult.OK)
- {
- textBox1.Text = openFileDialog.FileName;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- StartProcess(Environment.CurrentDirectory + "\\Core.ONH.Collection.Send.exe", new[] { textBox1.Text });
- }
- public bool StartProcess(string filename, string[] args)
- {
- try
- {
- string s = "";
- foreach (string arg in args)
- {
- s = s + arg + " ";
- }
- s = s.Trim();
- Process myprocess = new Process();
- ProcessStartInfo startInfo = new ProcessStartInfo(filename, s);
- myprocess.StartInfo = startInfo;
- myprocess.StartInfo.UseShellExecute = false;
- myprocess.Start();
- return true;
- }
- catch (Exception ex)
- {
- MessageBox.Show("启动应用程序时出错!原因:" + ex.Message);
- }
- return false;
- }
- }
- }
|