Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6345513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:50:16+00:00 2026-05-24T20:50:16+00:00

I am learning .net and writing a service by following the tutorial below http://www.beansoftware.com/NET-Tutorials/Create-Windows-Services.aspx

  • 0

I am learning .net and writing a service by following the tutorial below http://www.beansoftware.com/NET-Tutorials/Create-Windows-Services.aspx

The windows service gets installed successfully and it starts too. But when I change the file name or delete a file or add a file, it doesnt add any information to my log file which is in
C:\Folder\FolderLog.txt

I see 3 methods for FolderWatcher_** but I dont see a call to those in the code. I am very new to .net so I am not sure how they are being called

here is my complete code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;

    namespace Watcher
    {
        public partial class Watcher : ServiceBase
        {
            public Watcher()
            {
                InitializeComponent();
            }

            protected override void OnStart(string[] args)
            {

            }

            protected override void OnStop()
            {
            }

            private void FolderWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
            {
                TextWriter writer = new StreamWriter("C:\\folder\\FolderLog.txt", true);
                writer.WriteLine(DateTime.Now + " A new folder/file with name " + e.Name + " has been created. ");
                writer.Close();
            }

            private void FolderWatcher_Deleted(object sender, System.IO.FileSystemEventArgs e)
            {
                TextWriter writer = new StreamWriter("C:\\folder\\FolderLog.txt", true);
                writer.WriteLine(DateTime.Now + " A new folder/file with name " + e.Name + " has been deleted. ");
                writer.Close();
            }

            private void FolderWatcher_Renamed(object sender, System.IO.RenamedEventArgs e)
            {
                TextWriter writer = new StreamWriter("C:\\folder\\log.txt", true);
                writer.WriteLine(DateTime.Now + " A new folder/file with name " + e.Name + " has been renamed. ");
                writer.Close();
            }


        }
    }

I have followed every single step in that tutorial. I have not seen anything that descibes how these methods are called. Any help would be great

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:50:16+00:00Added an answer on May 24, 2026 at 8:50 pm

    Make sure you register the events of the watcher instance “FolderWatcher” to the events handlers in your code, you can do that at service designer or in the constructor of the service, like:

    public Watcher()
    {
        InitializeComponent();
    
        FolderWatcher.Created += FolderWatcher_Created;//when created FolderWatcher_Created will be called
        FolderWatcher.Deleted += FolderWatcher_Deleted;//when deleted call FolderWatcher_Deleted will be called
        FolderWatcher.Renamed += FolderWatcher_Renamed;//when renamed FolderWatcher_Renamed will be called
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Where can I find a good tutorial on learning ASP.NET MVC using VB.net 2008
I am writing a learning project in ASP.NET MVC. I have a page Books
So today I started learning ASP.NET. Unfortunately I haven't found any good tutorials online,
I'm learning ASP.NET MVC Framework, From some articles like this , it seems that
I'm learning ASP.NET MVC and bugged by one issue. In the HomeController, the Index
I'm still learning ASP.NET and I often see code like this throughout parts of
I'm just learning asp.net mvc and I'm trying to figure out how to move
Im in the process of learning asp.net 3.5, currently on webparts and co. Ive
I would like to start learning ASP.NET on a for-fun project. I'm hoping to
I'm a Java EE person who would like to climb the .NET learning curve.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.