我最近"转换"或者更确切地将我的方法导入到默认的Windows服务模板中.没有语法错误,它的编译没问题,但FileSystemWatcher方法由于某种原因不能正常工作,例如,当正常运行时,它会将已创建的所有进程写入process.lst,但是当作为服务运行时它不会执行这(可能与工作目录有关,因为它是一个服务?):
namespace WindowsService
{
class WindowsService : ServiceBase
{
/// <summary>
/// Public Constructor for WindowsService.
/// - Put all of your Initialization code here.
/// </summary>
public WindowsService()
{
this.ServiceName = "My Service";
this.EventLog.Source = "My Service";
this.EventLog.Log = "Application";
// These Flags set whether or not to handle that specific
// type of event. Set to true if you need it, false otherwise.
this.CanHandlePowerEvent = true;
this.CanHandleSessionChangeEvent = true;
this.CanPauseAndContinue = true;
this.CanShutdown = true;
this.CanStop = true; …Run Code Online (Sandbox Code Playgroud) 如果本地文件的时间戳早于服务器上的文件时间戳,如何从服务器下载文件,并让 C# 仅下载文件?在这种情况下,这两个文件具有相同的名称、扩展名等...
例如网络服务器中的文件:
http://www.test.com/test.txt
Run Code Online (Sandbox Code Playgroud)
本地计算机上的文件:
C:\test.txt
Run Code Online (Sandbox Code Playgroud)