Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.7k views
in .NET FTP by (320 points)
Hi All,

How to ensure file A completely transffered in location LA before we start to transfer file A from location LA to location LB?

Thanks!

Best Regards,
weihann.
________
DAIHATSU CONSORTE HISTORY

9 Answers

0 votes
by (162k points)
If you mean it is being transferred by different processes, then a common way is to transfer a file as MYFILENAME.TMP.

Once the file is transferred, rename to MYFILENAME.XXX.

The process waiting for this file polls on MYFILENAME.XXX, and when it finds it, the entire file will be present.
0 votes
by (320 points)
If you mean it is being transferred by different processes, then a common way is to transfer a file as MYFILENAME.TMP.

Once the file is transferred, rename to MYFILENAME.XXX.

The process waiting for this file polls on MYFILENAME.XXX, and when it finds it, the entire file will be present.


My apologize for not explaining my situation clearly in the first place.

below is my situation:
----------
1) Process A (client) will drop file A into location LA at a random time.
2) My process will pick up file A from location LA to location LB in a scheduled time frame.

Problem:
----------
How do i ensure when my process in 2) only pick up a complete file A to transfer?
________
Arizona Marijuana Dispensaries
0 votes
by (700 points)
What I did in this situation is exactly what support2 suggested. While I am transferring the file (your step 1) I put a .~prt extension on the end of it. Then at the very end of step 1 (when the transfer is complete), I rename the file to get rid of the temporary extension (.~prt). Then in step 2, just ignore files with a .~prt extension since they are partial files.
0 votes
by (320 points)
What I did in this situation is exactly what support2 suggested. While I am transferring the file (your step 1) I put a .~prt extension on the end of it. Then at the very end of step 1 (when the transfer is complete), I rename the file to get rid of the temporary extension (.~prt). Then in step 2, just ignore files with a .~prt extension since they are partial files.


sorry, process A is not under my control.... those are client files....
________
Vapir no2 vaporizer
0 votes
by (700 points)
Well, then you may be out of luck. The best thing you can do is assume that the file is locked while process A is running. It should be locked since something is writing to it. Just check to see if it is locked, and if it is then you know not to touch it.
0 votes
by (320 points)
Well, then you may be out of luck. The best thing you can do is assume that the file is locked while process A is running. It should be locked since something is writing to it. Just check to see if it is locked, and if it is then you know not to touch it.


how do i check that?
________
Make A Vaporizer
0 votes
by (700 points)
This function (written in C#) will return true if the file is locked or false if it is not. Basically, the only way to know if a file is locked is if you try to open it and you can't. That is why there is a try/catch in there. This function does assume that the file exists, so you should definitely verify that before calling into it.
public bool IsFileLocked(string fileName)
{
   try
   {
      System.IO.FileStream fs = System.IO.File.OpenWrite(fileName);
      fs.Close();
                return false;
   }
   catch (System.IO.IOException)
   {
      return true;
   }
}
0 votes
by (320 points)
This function (written in C#) will return true if the file is locked or false if it is not. Basically, the only way to know if a file is locked is if you try to open it and you can't. That is why there is a try/catch in there. This function does assume that the file exists, so you should definitely verify that before calling into it.
public bool IsFileLocked(string fileName)
{
   try
   {
      System.IO.FileStream fs = System.IO.File.OpenWrite(fileName);
      fs.Close();
                return false;
   }
   catch (System.IO.IOException)
   {
      return true;
   }
}


thanks! i will give this a try. thank u very much :P
________
150
0 votes
by (320 points)
This function (written in C#) will return true if the file is locked or false if it is not. Basically, the only way to know if a file is locked is if you try to open it and you can't. That is why there is a try/catch in there. This function does assume that the file exists, so you should definitely verify that before calling into it.
public bool IsFileLocked(string fileName)
{
   try
   {
      System.IO.FileStream fs = System.IO.File.OpenWrite(fileName);
      fs.Close();
                return false;
   }
   catch (System.IO.IOException)
   {
      return true;
   }
}


thanks! i will give this a try. thank u very much :P
opps... i am using FTP transfer. this option will not be able to use :(
________
Extreme vaporizer

Categories

...