Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
11k views
in Java FTP by
Hi, Iam trying to get my transfer to work, but every time I run the program it gives me a Access denied. (code=550) error when it gets to the ftp1.UploadFile(zipfileName, fname).

What I am trying to do is get my transfer to resume after a network connection has been lost and then restored. I test this by plugging out my network cable when I am running the first UploadFile, it then goes into the catch area where it tries to get the connection first (I plug in my cable again) , and then it should resume the transfer. If I run my code and do not try to simulate a lost connection my upload works 100%. Please help !!!!! Here is my coding:
if (ftp.IsConnected == true) 
{ 
  ftp.TransferType = FTPTransferType.BINARY; 
  try 
  { 
    ftp.ChangeWorkingDirectory(objFTPDetails.Directory); 
  } 
  catch 
  { 
  } 
  int start = zipfileName.LastIndexOf("\\"); 
  string fname = zipfileName.Substring(start + 1); 
  
  try 
  { 
    ftp.UploadFile(zipfileName, fname); 
    ftp.Close(); 
  } 
  catch (System.Exception ex1) 
  { 
    GetConnection(ftp, objFTPDetails); 
    ResumePut(ftp, objFTPDetails, zipfileName); 
  } 
} 


public static void GetConnection(FTPConnection ftp, CalicoWS.FTP objFTPDetails) 
{ 
  string x = ftp.IsConnected.ToString(); 
  if (bool.Parse(x) == true) 
  { 
    try 
    { 
      ftp.Close(); 
    } 
    catch 
    { 
    } 
  } 
  while (ftp.IsConnected == false) 
  { 
    try 
    { 
      ftp.Connect(); 
    } 
    catch 
    { 
    } 
  } 
} 

public static void ResumePut(FTPConnection ftp, CalicoWS.FTP objFTPDetails, string zipfileName) 
{ 
  ftp.Close(); 
  ftp.Dispose(); 
  
  //Here I totally create a new connection , just incase, tried it with old connection, gave same error 
  
  CalicoWS.CalicoWS objWS = new FTPResume.CalicoWS.CalicoWS(); 
  
  CalicoWS.FTP objFTPDetails1 = new FTPResume.CalicoWS.FTP(); 
  
  objFTPDetails1 = objWS.getDaybookFTPDetails(FTPResume.Settings.InstanceID); 
  FTPResume.Settings.FtpConnect = "True"; 
  
  FTPConnection ftp1 = new FTPConnection(); 
  
  ftp1.ServerAddress = objFTPDetails1.Hostname; 
  ftp1.UserName = objFTPDetails1.Username; 
  ftp1.Password = objFTPDetails1.Password; 
  
  
  ftp1.ServerPort = objFTPDetails1.Port; 
  ftp1.DeleteOnFailure = false; 
  
  ftp1.Connect(); 
  
  if (ftp1.IsConnected == true) 
  { 
    try 
    { 
      ftp1.ChangeWorkingDirectory(objFTPDetails1.Directory); 
    } 
    catch 
    { 
    } 
    
    ftp1.TransferType = FTPTransferType.BINARY; 
    
    int start = zipfileName.LastIndexOf("\\"); 
    string fname = zipfileName.Substring(start + 1); 
    
    try 
    { 
      if (ftp1.Exists(fname) == true) 
      { 
        ftp1.ResumeTransfer(); 
        ftp1.UploadFile(zipfileName, fname); \\ Here it boms out 
      } 
      else 
      { 
      } 
      ftp1.Close(); 
    } 
    catch (System.Exception ex1) 
    { 
      ftp1.Close(); 
    } 
  }
}

4 Answers

0 votes
by (162k points)
Please post the log file ...
0 votes
by
In my public static void ResumePut(FTPConnection ftp, CalicoWS.FTP objFTPDetails, string zipfileName)
procedure where I have the following code, must have a true for append and then it works:

try
{
if (ftp1.Exists(fname) == true)
{
ftp1.ResumeTransfer();
ftp1.UploadFile(zipfileName, fname,true);
}
else
{
}
ftp1.Close();
}
catch (System.Exception ex1)
{
ftp1.Close();
}
0 votes
by (140 points)
How can you change the password on a ftp account? Our office's webpage was hacked recently. (Fortunately, it wasn't a malicious hacker.) But, I'd like to change the password for our ftp site. I update the page via ftp, but our building services organization are the administrators. Can I change the password on my own, or do I need to work through the administrators?
_____________________
market samurai ~ marketsamurai ~ marketsamurai.com
0 votes
by (162k points)
Normally the administrators, although some servers support the CPWD command (but probably disabled).

Categories

...