Jump to content
  • Advertisement
Sign in to follow this  

upload image to ftp server C#

This topic is 3776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

id like to convert to png and upload data i have in a "Image" type to a ftp server.... how would i do that? im using C# .NET 3.5 EDIT:: i guess something like this... but it doesnt work...
      static void UploadImage(string filename, Image image)
                FileInfo fileInf = new FileInfo(filename);
                string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;
                FtpWebRequest reqFTP;

                // Create FtpWebRequest object from the Uri provided
                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(
                        "ftp://" + ftpServerIP + "/" + fileInf.Name));

                // Provide the WebPermission Credintials
                reqFTP.Credentials = new NetworkCredential(ftpUserID, 

                // By default KeepAlive is true, where the control connection is 
                // not closed after a command is executed.
                reqFTP.KeepAlive = false;

                // Specify the command to be executed.
                reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

                // Specify the data transfer type.
                reqFTP.UseBinary = true; ???

                // Notify the server about the size of the uploaded file
                //reqFTP.ContentLength = fileInf.Length; ???

                using (Stream strm = reqFTP.GetRequestStream())
                    image.Save(strm, ImageFormat.Png);

            catch(Exception ex)
                MessageBox.Show(ex.Message, "Upload Error");

[Edited by - Dragon_Strike on March 20, 2008 3:06:55 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!