Ads 468x60px

Thursday, August 30, 2012

how to upload file or image on FTP using uploader in using c#

In this web programming tutorial we will learn that how we can upload an image or file directly on FTP by using file uploader control in using c# see the below code it will help us by doing so.. just copy and paste.
public void ftpfile(string ftpfilepath)
     string ftphost = "Domain";
     //here correct hostname or IP of the ftp server to be given  
     string ftpfullpath = "ftp://" + ftphost + ftpfilepath;
     FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);
     ftp.Credentials = new NetworkCredential("Domain", "Password");
     //userid and password for the ftp server to given  
     ftp.KeepAlive = true;
     ftp.UseBinary = true;
     ftp.Method = WebRequestMethods.Ftp.UploadFile;
     // Resize Image is function to resize the image 
     System.Drawing.Image img1 = 
         ResizeImage(FileUpload1.PostedFile.InputStream, 84, 118);
     // Convert the image into bytes Array;
     byte[] buffer = ImageToByte(img1);
     // Send the image file in form of bytes
     Stream ftpstream = ftp.GetRequestStream();
     ftpstream.Write(buffer, 0, buffer.Length);

how to concatenate Strings in using C#

In this web programming tutorial we will learn that how we can concatenate strings in using c#. just copy and paste the below code.
 string practice = "Adress1" + "," Karachi ", "state" + "4600";