Tray Application that runs for a long time

Go To StackoverFlow.com

0

Possible Duplicate:
Writing a Windows system tray application with .NET

I want to develop a tray application. What this should do is it must keep looking for recently modified files.. once a file is get caught it a copy of that file to the web server. Therefore, user will be able to login to the website and later on user will be able to download those backing up files. what i want to know is how do i develop the tray application? Do i have to write a windows service for that? If so, i need a tray application to control the service (tray application must have sfunctionalities to start and stop service [Backup service], An option to choose the file extensions) I'm using c#. Thanks a lot in advance.

2012-04-04 19:42
by Fawzan Izy
http://stackoverflow.com/q/995195/884410Anurag Ranjhan 2012-04-04 19:45
https://github.com/hbons/SparkleShare http://sparkleshare.org - mattanja 2012-04-04 19:46
What makes you think you want a desktop app with a tray icon? Why not a service - David Heffernan 2012-04-04 19:48
@David Heffernan Actually this my project. But i have no idea on how to implement this. which is an automatic backup system. so i need to have a tray application that monitors file modifications and sends modified files to the web server. then user will be able to download those files later on whenever needed. hope u got my point. please suggest me how to this tray application that monitors file modifications. that must keep running on tray like Kaspersky anti-virus - Fawzan Izy 2012-04-04 19:52
Well, a service seems much more appropriate to me. Are you familiar with the difference between a windows service and a desktop app - David Heffernan 2012-04-04 19:54


0

Sounds pretty straightforward.

Create a basic WinForms app. The app's main window should start "minimized" and should not show in the taskbar. But, it should have a "NotifyIcon" component, which allows the app to show in the system tray. Double-clicking the NotifyIcon would restore the window, show the window in the taskbar and hide the NotifyIcon until the window is minimized or closed again.

This application can do the file watching on its own, or it can edit the configuration used by a Windows service; either way would work. Either way, you need to set up a FileSystemWatcher (or several of them) that monitors files in the directories the user wants you to check. When a FileSystemWatcher sees a file change, it'll fire an event that you can handle by performing the upload to the web server.

Just as an aside to the whole design; if you're implementing an online backup system (which it appears that you are), I would make sure that the user has access to several past iterations of the file, in case they want to restore a previous version. You should also have virus-checking; the last thing a user would need is for a virus to wreck their files AND for your backup system to have backed up the wrecked files.

2012-04-04 19:55
by KeithS
Well i implemented the tray application as u said. Thanks a lot - Fawzan Izy 2012-04-20 16:11


0

I personally wouldn't make it like a Windows Service, but would choose a simple application that "lives" on behind of system. It's easier to maintain and update, uninstall from the client (on his request). In short, for something simple I wouldn't go for Windows Service.

I would add a sys-tray component, with some menus. You can have a look at WPF NotifyIcon from Philipp Sumi.

One of menu items can have an item that registers executable to run on startup of the OS. You can achieve that with kind of code:

Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
Assembly curAssembly = Assembly.GetExecutingAssembly();
key.SetValue(curAssembly.GetName().Name, curAssembly.Location);

If for some reason, cause it's not very clear from your post, your application, indeed, goes to manage some serious amount of data on considerable production environment, go for WindowsService and manage all related to it stuff.

Hope this helps.

2012-04-04 19:50
by Tigran
Ads