Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Windows service to open folder

Windows service to open folder

Scheduled Pinned Locked Moved C#
question
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    milan
    wrote on last edited by
    #1

    Hi all, I have using FileSystemWatcher class so as to watch particular folder. If any new files get copied to it, windows explorer open the folder automatically. It works fine with console application but when it's been created as a windows service, it doesn't work. The code ---

    public class JobClass
    {
    public void startJob()
    {
    FileSystemWatcher watcher = new FileSystemWatcher();
    watcher.Filter = "*.*";
    watcher.Path = "c:\\DMSTemp";
    watcher.EnableRaisingEvents = true;
    watcher.Created +=new FileSystemEventHandler(watcher_Created);
    Console.ReadLine();

        }
        void watcher\_Created(object sender, FileSystemEventArgs e)
        {
            Process process = new Process();
            process.StartInfo.FileName = "explorer.exe";
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.Arguments = "c:\\\\DMSTemp";
            process.Start();
        }
        
    }
    

    From the onStart() event of WindowsService, JobClass's startJob method is invoked.

    protected override void OnStart(string[] args)
    {
    JobClass jobClass = new JobClass();
    jobClass.startJob();

        }
    

    Any idea? Thanks, milan

    satan

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups