Click here to Skip to main content
15,072,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have problem to move a image from my local folder to remote server folder. So please help me any one. I'm using asp.net and c# 4.0.
Posted
Comments
Nelek 2-Mar-13 5:17am
   
What have you tried?[^]
There are many ways to screw things up. Without more information from you, we can not know which one have you used.
sureshveera 2-Mar-13 23:39pm
   
I have using below coding but i got a error of Unable to connect to the remote server.

string source_file =C:\inetpub\wwwroot\static.eat-buddy\DK\PartnersImages\Test.jpg"
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp:204.97.222.24//static.eat-buddy.com/DK/Admin/" + imagerename.Replace("'", ""));
request.Method = WebRequestMethods.Ftp.UploadFile;

request.Credentials = new NetworkCredential("Username", "Pasword");


StreamReader sourceStream = new StreamReader(source_file);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;

Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();

1 solution

Hi,
local to remote, if you mean client to server, then below link would help you.
asp.net upload file example[^]
   

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