更新时间:2023-12-04 09:52:22
您编码的原因很可能不适用于Windows服务,因为您使用的是基于UI的组件,如listbox,textbox,openfile对话框等。
您可以在Windows服务中轻松使用文件系统观察程序。
Most likely the reasons you code is not working in a Windows Service is because you are using UI based components like listbox, textbox, openfile dialog, etc.
You can easily use a file system watcher in a Windows Service.
添加AnvilRanger所说的内容:Windows服务不能有UI - 它根本不能直接与用户交互,无论是输入还是输出。你不能使用表格,你不能使用文本框,你不能使用标签。您无法直接在服务中显示任何内容。只有用户登录后才能开始执行UI应用程序。
To add to what AnvilRanger says: a windows service cannot have a UI - it cannot interface directly with the user at all, either for input or output. You cannot use a form, you can't use textboxes, you can't use labels. You cannot directly display anything in a service. Only once the user has logged in can a UI app start to execute.