评论会员:游客 时间:2012/02/06
安德烈Kraak:看看这个例子:imgsrc=]
农Santosh:开始
public static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
}
}
public static void StopService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
}
catch
{
}
}
评论会员:RaviRanjankr 时间:2012/02/06
private void button5_Click(object sender, EventArgs e)
{
TextWriter tw = new StreamWriter("gridviewcontent.doc");
for (int x = 0; x < dgv1.Columns.Count; x++)
{
tw.Write(dgv1.Columns[x].HeaderText);
if (x != dgv1.Columns.Count - 1)
{
tw.Write(", ");
}
}
tw.WriteLine();
for (int x = 0; x < dgv1.Rows.Count - 1; x++)
{
for (int y = 0; y < dgv1.Columns.Count; y++)
{
tw.Write(dgv1.Rows[x].Cells[y].Value);
if (y != dgv1.Columns.Count - 1)
{
tw.Write(", ");
}
}
tw.WriteLine();
}
tw.Close();
}
的