Good hard to generate a two-dimensional code, and then to achieve the click "Save Picture", pop-up selection path to save the effect.
Look
stringQrcodeurl =""; stringUsername =""; protected voidBtnsave_click (Objectsender, EventArgs e) { //Create a pictureBitmap image = Create_imgcode (Qrcodeurl,5); //Save Picture stringServer_saveurl = Server.MapPath ("~/") +"Upload\\qrcode"; Saveimg (Server_saveurl, image); FileDownload (Server_saveurl+"\\"+ Username +". PNG"); } /// <summary> ///generate two-dimensional code images/// </summary> /// <param name= "Codenumber" >a string to generate a two-dimensional code</param> /// <param name= "Size" >size Size</param> /// <returns>Two-dimensional code image</returns> PublicBitmap Create_imgcode (stringCodenumber,intsize) { //creating a two-dimensional code generation classQrcodeencoder Qrcodeencoder =NewQrcodeencoder (); //Setting the encoding modeQrcodeencoder.qrcodeencodemode =Qrcodeencoder.encode_mode. BYTE; //Setting the Encoding measurement degreeQrcodeencoder.qrcodescale =size; //set the encoded versionQrcodeencoder.qrcodeversion =0; //set encoding error correctionQrcodeencoder.qrcodeerrorcorrect =qrcodeencoder.error_correction. M //generate two-dimensional code imagesSystem.Drawing.Bitmap image =Qrcodeencoder.encode (Codenumber); returnimage; } /// <summary> ///Save the picture on the server side/// </summary> /// <param name= "strpath" >Save Path</param> /// <param name= "img" >Image</param> Public stringSaveimg (stringstrpath, Bitmap img) { //save picture to directory if(!directory.exists (strpath)) { //if the current directory does not exist, createdirectory.createdirectory (strpath); } //file name stringfilename = strpath +"/"+ Username +". PNG"; if(file.exists (filename)) {returnfilename; } img. Save (filename, System.Drawing.Imaging.ImageFormat.Png); returnfilename; } /// <summary> ///WebForm Save the picture in the client/// </summary> /// <param name= "Fullfilename" ></param> Private voidFileDownload (stringfullfilename) {FileInfo DownloadFile=NewFileInfo (fullfilename); Response.Clear (); Response.ClearHeaders (); Response.Buffer=false; Response.ContentType="Application/octet-stream"; Response.appendheader ("content-disposition","attachment;filename="+Httputility.urlencode (Downloadfile.fullname, System.Text.Encoding.UTF8)); Response.appendheader ("Content-length", DownloadFile.Length.ToString ()); Response.WriteFile (Downloadfile.fullname); Response.Flush (); Response.End (); }
Are online search, looking for a long time in the thought of saving the image to the server, and then download from the server to the customer service side.
C # webform site picture Save code