Jump to content

FTP upload

- - - - -

  • Please log in to reply
2 replies to this topic

#1
rocshy

rocshy

    Newbie

  • Members
  • Pip
  • 2 posts
Hi,

I'm trying to make an app that will upload files on a ftp server but I keep getting this error 550 Can't change directory to (dir name): No such file or directory. I've checked the path and it's good.

Can someone tell me how to correct this ? I've tested my code on a local server and it works. What am I missing ?

#2
wwarren

wwarren

    Learning Programmer

  • Members
  • PipPipPip
  • 60 posts
If you could post some of the code you're using then it will be easier to help you out.
Sounds like either your 2 ftp servers are configured differently maybe you need to use absolute, instead of relative paths when changing directory.

That's all i can guess given the facts at hand

Cheers

#3
rocshy

rocshy

    Newbie

  • Members
  • Pip
  • 2 posts

wwarren said:

If you could post some of the code you're using then it will be easier to help you out.
Sounds like either your 2 ftp servers are configured differently maybe you need to use absolute, instead of relative paths when changing directory.

That's all i can guess given the facts at hand

Cheers

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri ("ftp://" + ftpAddress + "/" + fileName));


request.Method = WebRequestMethods.Ftp.UploadFile;

request.Credentials = new NetworkCredential("roxy", "roxana");
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = true;
request.Proxy = null;

Stream ftpStream = request.GetRequestStream();

FileStream file = File.OpenRead("d:\\Test_Upload.txt");

int len = 1024;
byte[] buffer = new byte[len];
int bytesRead = 0;

do
{
bytesRead = file.Read(buffer, 0, len);
ftpStream.Write(buffer, 0, bytesRead);
}
while (bytesRead != 0);

file.Close();
ftpStream.Close();




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users