Click here to Skip to main content
15,890,982 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting an error while i run the code below. This happens when only i run the exe on a Win XP machine. For WIN-7, it is working fine.
C#
private bool GetFileSize(FileInfo targetFI, long FileUploadedSize, string g_Subdivision,TMWaitDialog tmwaitdialog)
          {
              FtpWebRequest reqFTP;
              long fileSize = 0;
              try
              {
                  string Uri = string.Empty;
                  Uri = @"ftp://" + ftpServerIP + "/" + g_Subdivision + "/" + targetFI.Name.ToUpper().Trim();
                  reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(Uri.Trim()));
                  reqFTP.Method = WebRequestMethods.Ftp.GetFileSize;
                  reqFTP.UseBinary = true;
                  reqFTP.KeepAlive = false;
                  reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                  FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                  Stream ftpStream = response.GetResponseStream();
                  fileSize = response.ContentLength;
                  
                  ftpStream.Close();
                  response.Close();
                return (fileSize == FileUploadedSize);
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.Message);
                  return false;
              }
             
          }


The error i am getting when i run the exe is mentioned below.
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
Note: g_Subdivision denotes ftp folder name
The filepath was correct and the file is existing in the ftp.
Can somebody help me to sort the issue.
Posted
Updated 13-Jan-12 20:28pm
v2
Comments
manognya kota 14-Jan-12 2:23am    
Hi,
Can you post the complete error message?
Arun Ashok 14-Jan-12 2:28am    
The error i am getting when i run the exe is mentioned below.
The remote server returned an error: (550) File unavailable (e.g., file not found, no access).
Note: g_Subdivision denotes ftp folder name
The filepath was correct and the file is existing in the ftp.
manognya kota 14-Jan-12 2:33am    
Did u try this,

In the server Go to Control Panel>Internet information Services, expand FTP Sites, right click in Default FTP Site and go to Properties, in the tab Particular directory check Write and press OK.
Arun Ashok 14-Jan-12 3:28am    
in server the site having write permissions enabled, then also i am getting the same error.
manognya kota 14-Jan-12 3:49am    
did u try manual FTP from this system?Is it working?

Hi,

Few queries:

1.Are the 2 systems different?
2.Did you check whether the system has access permission for that FTP site?
 
Share this answer
 
Hi All,

The problem was not because of the permissions. The ftp site is having permissions for read/write etc.
I scanned the ftp site with a virus scanner and, the code is working with both Win 7 and Win XP. So I searched for the root cause of the problem and I found that the, error is because of the FTP response timeout. Due to virus affection in the ftp, the FTP response is trying to get it from the FTP. After listening several minutes, it goes to timeout. Now the exe with the listed code is working for both OS.

Thanks you for helping...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900