Solved

Detect Newly Created Files (of Specific *.??? 3 letter extention) in VS 2013 C#

Posted on 2013-12-21
2
363 Views
Last Modified: 2013-12-21
Hello!

I need example code in C# that will detect PDF files that are uploaded via Windows file share. (For me, this will be used to detect Acrobat PDF files from a multi-purpose scanner to integrate into a larger management system.)

Please: This should be simple, concise & bug-free Visual Studio 2013 C# code for Windows.

Thank you in advance! Happy Coding! :)
0
Comment
Question by:DumbBoxRox
2 Comments
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 500 total points
ID: 39733624
Please: This should be simple, concise & bug-free Visual Studio 2013 C# code for Windows.
Note that Experts Exchange is not a freelance coder website. If you are looking for someone to write a full solution, you would have better success probably at some place like freelancer.com. We will certainly do our best to help, though.

What you are wanting to do is quite easy. The FileSystemWatcher class was designed to do exactly that. Try something like this
using System.IO;
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "C:\directoryToSearch"; // edit this to the path you want to search
watcher.Filter = "*.pdf"; // find pdfs
watcher.IncludeSubdirectories = true; // also watch subdirectories
watcher.Created += new FileSystemEventHandler(NewFileHandler); // set up the handler
watcher.EnableRaisingEvents = true; //start listening

Open in new window


Then the event handler would look like this

private static void NewFileHandler(object source, FileSystemEventArgs e)
{
    // Do your handling here
   Console.WriteLine("New file seen at: " +  e.FullPath);
}

Open in new window

0
 

Author Closing Comment

by:DumbBoxRox
ID: 39733771
Tommy,

Yes. I was looking just for a snippet, not a full solution. I understand your comment though because of abuse. I have not used the Microsoft .NET API for quite some time, and wanted a professional answer (and you gave me one), so I will reward you with your full amount of points.

Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now