Solved

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

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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 46
VB.net Move a class from Solution Items to a project 2 23
MediaHelp 4 23
i have to take the screenshot of command prompt? how to do this? 1 37
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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