Solved

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

Posted on 2014-10-07
4
691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

690 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