At the moment it places a jpg in the destination folder, but the file is not viewable or contains no information?
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftpserver" + "/" + label1.Text + "" + "Winter.jpg");
request.Method = WebRequestMethods.Ftp.UploadFile;
//Path.GetFileName(filePath));
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential("username", "password");
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(@"C:\\Winter.jpg");
I feel my problem is here somewhere?
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();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();

VulpesRank #55 · 29.2K reputationPosted Mar 26, 2012, 6:51 AM EDT
mike DelvottiRank #7,298 · 244 reputationPosted Mar 26, 2012, 7:11 AM EDT
Could i be a bit cheeky and ask another quick question? at the moment i pull the image from: (@"C:\\Winter.jpg"); but lets say the image was already in pictureBox1 could i send that direct to ftp with something like:
StreamReader sourceStream = new StreamReader(Picturebox1.image);
or is that way off the mark?
VulpesRank #55 · 29.2K reputationPosted Mar 26, 2012, 7:21 AM EDT
Prime bRank #2,035 · 712 reputationPosted Mar 26, 2012, 7:25 AM EDT
VulpesRank #55 · 29.2K reputationPosted Mar 26, 2012, 7:28 AM EDT
Prime bRank #2,035 · 712 reputationPosted Mar 26, 2012, 7:36 AM EDT
mike DelvottiRank #7,298 · 244 reputationPosted Mar 26, 2012, 7:46 AM EDT
Thanks once again :)