C# WebCam Service with FTP and Installer


I got tired looking for an app to write a snap shot from my camera to disk that was free, no adware and no advertising on the image. I found a guy who wrapped the DirectX Library in C# - WHAT A CHAMP! Here's a link to him. Anyway, he has a full library called DShowNET and I call into that, made a Windows service that always runs when your pc is on. I added a full FTP library that extended from Jaimon Mathew.


The package comes as 1 project & a dll (DShowNET)

  • WebCamService.cs
  • FtpClient.cs
  • Capture.cs
  • WebCamInstaller.cs

Now, using the DShowNET library is a little tricky, and just to get a photo out of the webcam tool some 400 lines of code. I extended the Sample Grabber supplied with DShowNET and added the reset event so thet the photo could be taken syncronously.

The worst problem was making it stable, but this has been running on my workstation now for 20+ days without a restart. The most important code for stability is in the CloseInterfaces method - note the extensive try/catches - everything must be cleaned up, otherwise strange errors (including bluesceens) will be observed.

The ftp library I extended so I fould use it as a full featured ftp client. I have added it to this project so I can upload to the server.


  • DirectX 8.1
  • .NET Framework
  • Visual Studio .NET (if you plan to edit it of course...)
  • A windows OS that supports Windows Services (2K,XP)
  • Any DirectX supported Video in device (Tuner, Capture, Camera etc...)
  • 5 Minutes of your time


The Installer component is used to install the service with the command:

C:\>installutil.exe D:\projects\webcam\webcamservice\bin\debug\webcamservice.exe

You will also need to edit the config file to reflect your needs:

<add key="path" value="D:\Projects\WebCamService\out\WebCam.jpg"/>
<add key="CaptureCycleSeconds" value="10"/>
<add key="KeepOldImageCount" value="20"/>
<add key="FtpServer" value="???"/>
<add key="FtpUserName" value="???"/>
<add key="FtpPassword" value="???"/>
  • Path is where you wish to upload the pic too.
  • CaptureCycleSeconds is how long to wait before taking another photo ( add in capture time to 11+ seconds )
  • KeepOldImageCount is to hold the last n photos taken
  • The rest are pretty explanatory

Now you cans start and stop the service with the following commands:

net start WebCamService net stop WebCamService

The service will run in the background, and be started when your machine boots, NOT when you login.

You might also like...


Dan Glass


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Before software should be reusable, it should be usable.” - Ralph Johnson