• 大小: 0.11M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-29
  • 语言: C#
  • 标签: 发布  程序  服务  

资源简介

程序发布服务(安装/卸载/启动/停止服务)

资源截图

代码片段和文件信息

using System;
using System.ServiceProcess;
using System.IO;

namespace MyWindowsService
{
    public partial class MyService : Servicebase
    {
        public MyService()
        {
            InitializeComponent();
        }

        string filePath = @“D:\MyServiceLog.txt“;

        protected override void onstart(string[] args)
        {
            using (FileStream stream = new FileStream(filePathFileMode.Append))
            using (StreamWriter writer = new StreamWriter(stream))
            {
                writer.WriteLine($“{DateTime.Now}服务启动!“);
            }
        }

        protected override void onstop()
        {
            using (FileStream stream = new FileStream(filePath FileMode.Append))
            using (StreamWriter writer = new StreamWriter(stream))
            {
                writer.WriteLine($“{DateTime.Now}服务停止!“);
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-14 15:23  MyWindowsService\
     目录           0  2017-07-14 15:01  MyWindowsService\.vs\
     目录           0  2017-07-14 15:01  MyWindowsService\.vs\MyWindowsService\
     目录           0  2017-07-14 15:01  MyWindowsService\.vs\MyWindowsService\v14\
     文件       61952  2017-07-14 16:59  MyWindowsService\.vs\MyWindowsService\v14\.suo
     目录           0  2017-07-14 15:14  MyWindowsService\MyWindowsService\
     文件        1529  2017-07-14 15:24  MyWindowsService\MyWindowsService.sln
     目录           0  2017-07-14 15:02  MyWindowsService\MyWindowsService\bin\
     目录           0  2017-07-14 15:15  MyWindowsService\MyWindowsService\bin\Debug\
     文件        6656  2017-07-14 15:15  MyWindowsService\MyWindowsService\bin\Debug\MyWindowsService.exe
     文件       19968  2017-07-14 15:15  MyWindowsService\MyWindowsService\bin\Debug\MyWindowsService.pdb
     文件       22688  2017-07-14 15:01  MyWindowsService\MyWindowsService\bin\Debug\MyWindowsService.vshost.exe
     文件         490  2016-07-16 19:44  MyWindowsService\MyWindowsService\bin\Debug\MyWindowsService.vshost.exe.manifest
     目录           0  2017-07-14 15:02  MyWindowsService\MyWindowsService\bin\Release\
     文件         952  2017-07-14 15:08  MyWindowsService\MyWindowsService\MyService.cs
     文件        1098  2017-07-14 15:04  MyWindowsService\MyWindowsService\MyService.Designer.cs
     文件        3266  2017-07-14 15:14  MyWindowsService\MyWindowsService\MyWindowsService.csproj
     目录           0  2017-07-14 15:01  MyWindowsService\MyWindowsService\obj\
     目录           0  2017-07-14 16:01  MyWindowsService\MyWindowsService\obj\Debug\
     文件        1623  2017-07-14 16:01  MyWindowsService\MyWindowsService\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6883  2017-07-14 15:12  MyWindowsService\MyWindowsService\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         901  2017-07-14 15:15  MyWindowsService\MyWindowsService\obj\Debug\MyWindowsService.csproj.FileListAbsolute.txt
     文件         950  2017-07-14 15:15  MyWindowsService\MyWindowsService\obj\Debug\MyWindowsService.csproj.GenerateResource.Cache
     文件        2225  2017-07-14 15:15  MyWindowsService\MyWindowsService\obj\Debug\MyWindowsService.csprojResolveAssemblyReference.cache
     文件        6656  2017-07-14 15:15  MyWindowsService\MyWindowsService\obj\Debug\MyWindowsService.exe
     文件       19968  2017-07-14 15:15  MyWindowsService\MyWindowsService\obj\Debug\MyWindowsService.pdb
     文件         180  2017-07-14 15:15  MyWindowsService\MyWindowsService\obj\Debug\MyWindowsService.ProjectInstaller.resources
     目录           0  2017-07-14 15:01  MyWindowsService\MyWindowsService\obj\Debug\TempPE\
     文件         538  2017-07-14 15:14  MyWindowsService\MyWindowsService\Program.cs
     文件         420  2017-07-14 15:13  MyWindowsService\MyWindowsService\ProjectInstaller.cs
     文件        2073  2017-07-14 15:13  MyWindowsService\MyWindowsService\ProjectInstaller.Designer.cs
............此处省略39个文件信息

评论

共有 条评论