?
Solved

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

Posted on 2014-10-07
4
Medium Priority
?
812 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 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

741 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