0

I am writing a program for a client in VB.net that will run in the background monitoring a directory where multiple files throughout the day will be deposited into it. I am not concerned about the coding aspect of this project as much as I am concerned about how to approach it.

There are some things that I want to keep in mind as I build this application: 1. Program must start when the computer is started/restarted 2. I need it to run in the background with minimal resources 3. The user needs to be able to interact with the program to set it up and/or read from the log file

With that in mind, I am wanting to know what is best approach: 1. Should I run it in Windows Services? 2. Should I just build it as a regular Windows form and have it minimize to the system tray? 3. Would it be better to combine both of the above questions? Will this approach use more resources? 4. Is there anything I have overlooked? Maybe a better way to approach this?

rlearning
  • 35
  • 5
  • 1
    https://stackoverflow.com/questions/15017506/using-filesystemwatcher-to-monitor-a-directory – Renat Jul 08 '19 at 12:46
  • 5
    If you want it to start even when a user has not/is not logged on you need a service (and a second desktop application to interact with that service) – Alex K. Jul 08 '19 at 12:46

1 Answers1

1

I would suggest to create an C# Console Application you can simply run it on Auto Start to have it launch on boot.

To monitor the directory you can use FileSystemWatcher which is pretty much made for what you are trying to do.

Freddy789
  • 506
  • 4
  • 15
  • SinceI have never built much using consoles, I need you to help me out a bit. I need the user to pass parameters to it like where the files are located, email address, and where does the user want the log file located. – rlearning Jul 08 '19 at 13:06
  • You can get Userinput on differrent ways you could use a file and read its content or just do a read line `string filepath = Console.ReadLine();` and than use the string in your code. – Freddy789 Jul 08 '19 at 13:10
  • If you use the ReadLine way its important to keep in mind that the user will have to enter the Input everytime it starts so it might not be the best way to get input. – Freddy789 Jul 08 '19 at 13:13
  • Sounds quick and easy. One last question though, will the console window have to stay open while running or is there a way that it can stay in the background out of sight? – rlearning Jul 08 '19 at 13:13
  • Im unsure how you can do it but a quick google search should show you how if its possible but keep in mind if you want to read user input with readline youre gonna need a console window where the user can write in – Freddy789 Jul 08 '19 at 13:18
  • After thinking about it again i would use [File.ReadAllLines](https://learn.microsoft.com/de-de/dotnet/api/system.io.file.readalllines?view=netframework-4.8) with this you only have to enter the Inputs once in a file and the programm can run without any userinput – Freddy789 Jul 08 '19 at 13:42