0

I've been trying to finish up a web scraper for a website of mine and have hit a stumbling block on the folder creation for image storage

My code looks like this:

//ftpUser and ftpPass are set at the head of the class

FtpWebRequest lrgRequest = (FtpWebRequest) FtpWebRequest.Create("ftp://ftp.mysite.com/httpdocs/images/large/imgFolder");
lrgRequest.Credentials = new NetworkCredential(ftpUser, ftpPass);
lrgRequest.KeepAlive = false;
lrgRequest.Method = WebRequestMethods.Ftp.MakeDirectory;
FtpWebResponse response = (FtpWebResponse) lrgRequest.GetResponse();
Console.WriteLine(response);

When i run this code it gets to the response and throws the error 550 saying the folder isn't found

I've compared my approach to a number of examples and by the standard approach it should work. The ftp address is valid and has been checked and i'm wondering is there an issue with my server that is stopping this or is my C# causing the problem If anyone needs any more info please just say

As always any help is greatly appreciated

Regards
Barry

BarryH1987
  • 65
  • 12

1 Answers1

0

Definition of FTP 550:

Requested action not taken. File unavailable (e.g., file not found, no access).

I'd check you have the appropriate permissions (or you app does) and verfiy that the file does indeed exist.

Since you are getting a response code, I doubt your code above is the cause of the problem. However you could always check the AuthenticationLevel and ImpersonationLevel to see if these provide any useful information.

m.edmondson
  • 30,382
  • 27
  • 123
  • 206
  • I've been checking my through FileZilla when the code runs if the folder has been created but it doesn't appear, which is why i'm thinking it may be a permissions is as you say, but im concerned there is something i'm missing in the c# relevant to such permissions.Could that be a possibility? – BarryH1987 Jun 28 '12 at 17:46
  • You could check / set the AuthenticationLevel and the ImpersonationLevel so see if these are as expected - but other that that your code is golden. – m.edmondson Jun 28 '12 at 18:01
  • Many thanks for the quick response.I'll check those two parameters, hopefully that is where the problem lies – BarryH1987 Jun 28 '12 at 18:03