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();
VulpesPosted Mar 26, 2012, 10:51 AM
mike DelvottiPosted Mar 26, 2012, 11:46 AM
Thanks once again :)
Prime bPosted Mar 26, 2012, 11:36 AM
VulpesPosted Mar 26, 2012, 11:28 AM
Prime bPosted Mar 26, 2012, 11:25 AM
VulpesPosted Mar 26, 2012, 11:21 AM
mike DelvottiPosted Mar 26, 2012, 11:11 AM
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?