Solved

C# - how to check file has finished being written to from a ftp?

Posted on 2014-10-07
4
434 Views
Last Modified: 2014-10-07
We have a server which receives files by SFTP into a given directory
I have a C# program which periodically checks the directory for files then sends them to another server.
The program sends anything it finds to the second server then deletes it from the first server.
How can I make sure that I don't try to send a file that has not been fully FTPd to the first server?
I'm using a windows form with C# in visual studio 2008.
0
Comment
Question by:AlHal2
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 40365643
There are usually two approaches

1) Use a marker file to indicate that all other files have been uploaded.
2) When you see a file on SFTP for the first time, capture its modified date and size and then check it again after a set amount of time (5 minutes?). If the size has changed, the file may still be being uploaded. If not, its completely uploaded.
0
 

Author Comment

by:AlHal2
ID: 40365670
Thanks codeCruiser.  I'm using the System.IO reference in my project.  It doesn't have the modified date and size.  It only has the properties here.
http://msdn.microsoft.com/en-us/library/system.io.filesysteminfo_properties(v=vs.90).aspx
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 40365690
You need to create a FileInfo object and then use the LastWriteTime

http://msdn.microsoft.com/en-us/library/system.io.fileinfo(v=vs.110).aspx
0
 

Author Closing Comment

by:AlHal2
ID: 40365729
Thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

17 Experts available now in Live!

Get 1:1 Help Now