我正在尝试用C#检查服务,我已添加了 System.ServiceProcess.dll
虽然我收到错误:
错误2找不到类型或命名空间名称'ServiceController'(您是否缺少using指令或程序集引用?)D:\ App\Form1.cs 247 13 App
我的代码如下:
private void button13_Click(object sender, EventArgs e)
{
ServiceController sc = new ServiceController("Spooler");
if (sc.Status == ServiceControllerStatus.Running)
{
MessageBox.Show("The service is running.");
}
}
Run Code Online (Sandbox Code Playgroud)
我是否需要"使用"声明?
有人可以演示如何将文本文件中的文本,例如test.txt插入到可视化C#表单上的Label控件中