Solved

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

Posted on 2014-10-07
4
629 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

738 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