I have a program that checks a directory of zip files which get uploaded (via FTP) to my server daily (from different clients), each zip needs to contain a series of particular data files, so I am using the ZipArchive class to open the file, check the contents and make sure it contains the files we need and also make sure they have been recently updated (to make sure we're not uploading an old copy)
My program works for the most part, the problem I am facing is that if a file is currently being uploaded while Im trying to check it, my checker program is freezing. I cant seem to find any way around it.
Here is what Ive tried:
using (var zip = ZipFile.OpenRead("FileName")) // <--This is where it freezes.
{
// Check the contents
}
and I tried this:
using (var fs = File.OpenRead("FileName"))
{
using (var zip = new ZipArchive(fs, ZipArchiveMode.Read)) // <-- This is where it freezes.
{
// Check the contents
}
}
Ultimately I would just like it to throw an exception so I can continue onto the next file.
If anyone has had a similar issue or have any suggestions on what I can try it would be appreciated.