FTP, GetResponse (), error 550 File not available

I created a small application for Windows forms to upload a file to one of our ftp client sites. But the problem that I encountered is that when I run this application on my local computer, it successfully downloads the file. But if I run this program on our server, I get this error message:

the remote server returned an error: (550) The file is not available (for example, the file was not found, cannot access the file), in this line is 'objFTPRequest.GetRequestStream ();'.

Does anyone know why? Do I need to configure a firewall or something else? Here is my code;

FileInfo objFile = new FileInfo(filename); FtpWebRequest objFTPRequest; // Create FtpWebRequest object objFTPRequest = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/outbox/" + objFile.Name)); // Set Credintials objFTPRequest.Credentials = new NetworkCredential(ftpUserName, ftpPassword); // By default KeepAlive is true, where the control connection is // not closed after a command is executed. objFTPRequest.KeepAlive = false; // Set the data transfer type. objFTPRequest.UseBinary = true; // Set content length objFTPRequest.ContentLength = objFile.Length; // Set request method objFTPRequest.Method = WebRequestMethods.Ftp.UploadFile; // Set buffer size int intBufferLength = 16 * 1024; byte[] objBuffer = new byte[intBufferLength]; // Opens a file to read FileStream objFileStream = objFile.OpenRead(); // Get Stream of the file Stream objStream = objFTPRequest.GetRequestStream(); int len = 0; while ((len = objFileStream.Read(objBuffer, 0, intBufferLength)) != 0) { // Write file Content objStream.Write(objBuffer, 0, len); } objStream.Close(); objFileStream.Close(); 
+17
c # file-upload ftp
Jul 04 '13 at 13:37
source share
11 answers

This error can be caused by several reasons, such as a file missing from the server, security permissions on the file, etc. etc.

First you need to find out the exact cause of the error. This can be achieved using the following code -

 try { //Your code } catch(WebException e) { String status = ((FtpWebResponse)e.Response).StatusDescription; } 

Once you get the exact cause of the error, you can continue to resolve it.

Here are the links you can send

http://forums.asp.net/t/1777881.aspx/1

http://nickstips.wordpress.com/2010/10/25/c-ftp-upload-error-the-remote-server-returned-an-error-550-file-unavailable-eg-file-not-found- no-access /

http://www.dreamincode.net/forums/topic/76361-file-upload-to-server/

http://forums.asp.net/t/1374306.aspx/1

+24
Jul 04 '13 at 14:14
source share

Try the following: ftp: //xxx.xxx.xx.xx: 21 // path / filename

"//" after the server address launches you in the root directory. Although I had: ftp: //xxx.xxx.xx.xx: 21 / path / filename , this did not lead me to the correct directory.

+12
Dec 15 '14 at 15:10
source share

I met the same problem, and this is what I did:

  • Check if the OS has the right to write. Find the ftp => right click => properties => security folder, then you should know what you should do
  • Check that the ftp server opens the write permission to the user you registered. Open IIS => click on ftp site => ftp Authorization Rules => add allow rules => select a user or group to set permissions
  • Check the directory on the ftp server, do the same on element 2.

I can use four images to show the rights that need to be set: enter image description here

enter image description hereenter image description hereenter image description here

+7
Jul 09 '13 at 17:07 on
source share

It could be easier.

I ran into a similar problem and I tried all the proposed solution, but no one worked. I understand how it looks like this: take a look

Incorrect code at my end

  Dim request As Net.FtpWebRequest = CType(FtpWebRequest.Create("ftp://xxx.xxx.xxx.xxx/files"), FtpWebRequest) 

Change it in this simple one:

  Dim request As Net.FtpWebRequest = CType(FtpWebRequest.Create("ftp://xxx.xxx.xxx.xxx/files/youfilename.ext"), FtpWebRequest) 

then processed with a request for filling and sent to the server :)

What all.

Verify that all permissions on the server are working properly and using the correct credentials.

+4
Apr 03 '14 at
source share

To solve this problem, you need to force the System.Net.FtpWebRequest command to revert to the old behavior of how it was used to work in .Net Framework 2.0 / 3.5 and issue an additional CWD command before releasing the actual command.

To do this, you must add the following code before any instance of the System.Net.FtpWebRequest class is called. The code below needs to be called only once, since it changes the settings of the entire application domain.

 private static void SetMethodRequiresCWD() { Type requestType = typeof(FtpWebRequest); FieldInfo methodInfoField = requestType.GetField("m_MethodInfo", BindingFlags.NonPublic | BindingFlags.Instance); Type methodInfoType = methodInfoField.FieldType; FieldInfo knownMethodsField = methodInfoType.GetField("KnownMethodInfo", BindingFlags.Static | BindingFlags.NonPublic); Array knownMethodsArray = (Array)knownMethodsField.GetValue(null); FieldInfo flagsField = methodInfoType.GetField("Flags", BindingFlags.NonPublic | BindingFlags.Instance); int MustChangeWorkingDirectoryToPath = 0x100; foreach (object knownMethod in knownMethodsArray) { int flags = (int)flagsField.GetValue(knownMethod); flags |= MustChangeWorkingDirectoryToPath; flagsField.SetValue(knownMethod, flags); } } 

http://support.microsoft.com/kb/2134299

+1
Nov 06 '13 at 21:44
source share

Just to throw my hat in the ring, I got the same error. When FTPRequest requested files from an FTP service on the same computer (same IP address). In the request, I used the IP address of the device, but as soon as I changed it to 127.0.0.1, it worked. Interestingly, requests from other IP addresses were processed and files downloaded, and not on their own.

Hope someone helped.

0
Nov 16 '15 at 1:50
source share

When I had the same problem, I tried all the above, and after a day I realized that the path I created for uri having a space between "/" and the folder name

 string uri="192.168.1.101/ Sync/Image.jpg"; 

the specified string should be

 string uri="192.168.1.101/Sync/Image.jpg"; 

this small error also produces the same error and is a valid error because it is an invalid path for our file if it contains any spaces between the "/" and the folder / file name

0
Sep 15 '16 at 9:14
source share

I had the same problem when I compared with ftpuri and User Name Path, this is allowed. When I create ftp access, I chose the path as / directory name

in ftpuri, when I included the directory name that gave the error, and when I deleted the directory name, it is resolved.

ftpuri with error

" ftp://www.example.com/Project/yourfilename.ds "

enabled by ftpuri

" ftp://www.example.com/yourfilename.ds "

access folder

ftp "/ Project"

0
Jan 11 '17 at 15:56 on
source share

I also had this problem recently. I found that when I use ftpUploadFile, the program tries to put the file in the ftp root folder. The normal ftp command line worked fine. However, issuing the pwd command from the ftp command prompt showed that this particular server installed a different current directory upon login. Changing my ftpUploadFile to include this folder resolved the issue.

0
Feb 01 '17 at 13:54 on
source share

Verify that the outbox destination folder exists. This was my problem with error 550.

Just create the target file "output" before downloading.

 try { WebRequest request = WebRequest.Create("ftp://" + ftpServerIP + "/outbox"); request.Credentials = new NetworkCredential("user", "password"); request.Method = WebRequestMethods.Ftp.MakeDirectory; using (var resp = (FtpWebResponse)request.GetResponse()) { Console.WriteLine(resp.StatusCode); } } catch (WebException ex) { FtpWebResponse response = (FtpWebResponse)ex.Response; if (response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable) { response.Close(); //already exists } else { response.Close(); //doesn't exists = it another exception } } 
0
Jul 31 '17 at 12:30
source share

I had this problem. Filezilla was fine .net was not. It was a wordpress server. To make it work, I changed my code:

ftp://XXX.XXX.XXX.XXX//folder// "+ txtFile.Text

at

ftp: // [FTPNAME] @ XXX.XXX.XXX.XXX // "+ txtFile.Text

and now, fortunately, it works.

I do not know if this applies to FTP folders for Wordpress.

0
Oct 25 '17 at 9:43 on
source share



All Articles