0

my background is specific to ASP.NET and SQL Server, so this new project of mine is a bit challenging for me.

I have an third party application that I cannot change that updates an XML file. When that XML file is updated, I want to launch a browser ( internet explorer ) with a URL built based on the some of the attributes of the XML file.

I have seen various examples of file watchers, and am not worried about that ( although input from this group would be gladly excepted ).

My question is to what type of project to use? My first thought was to use a service, so the users would not have to worry about it or be able to shut it off, but then I read you don't get a "desktop" when you use a service so I am a bit confused in terms of the direction to take.

Neo
  • 3,309
  • 7
  • 35
  • 44

2 Answers2

1

A Windows Forms application is likely the simplest tool for this task. You'll have access to the user's desktop (not simple for a service) and you don't need to have any windows open for the application (not simple for a console application).

See https://stackoverflow.com/a/9413568/1125059 for how to create a Forms application without opening an initial form window.

You may want to provide a system tray icon for the application to control its state if you don't have a mechanism for that already.

Community
  • 1
  • 1
Dion Williams
  • 165
  • 1
  • 7
  • I tried this approach, but the windows forms app runs once then shuts down, even though there isn't a close button. – Neo Sep 13 '16 at 17:35
  • 1
    The Main method mustn't be allowed to exit early. After setting up the events for the FileWatcher, the last line of the Main method should be [`Application.Run();`](https://msdn.microsoft.com/en-us/library/ms157900(v=vs.110).aspx) to keep the application running and processing the application message loop. – Dion Williams Sep 13 '16 at 22:13
  • Thanks for your help. Now I just got to figure out why the change event is firing twice, even though I only have the NotifyFilters.LastWrite enabled. – Neo Sep 14 '16 at 11:08
-1

If you need Internet Explorer to launch when the attributes of this file changes and no other interface, then I would create a service project. Anything else needed, you could launch from the service at the same time.

This assumes you would only want it to watch in the background and not needed to be managed by whomever is logged on.

Paul
  • 36
  • 5
  • This does not work due to the separation of the desktop access and a windows service – Neo Sep 13 '16 at 17:34