"C #" multiple pictures are written to string strings, separating the storage

Source: Internet
Author: User

Using system;using system.collections.generic;using system.linq;using system.text;using System.IO;using system.drawing;using system.drawing.imaging;namespace Picture converted to string {class program {static void Main (string[] Arg        s) {img2str (); } public static void Img2str () {string[] Imge_file = {"E:/01.jpg", "e:/02.jpg", "e:/03.jpg", "E            :/04.jpg "," e:/05.jpg "," e:/06.jpg "," e:/07.jpg "," e:/08.jpg "," e:/09.jpg "," e:/10.jpg "};            FileStream Img0 = new FileStream (imge_file[0], FileMode.Open);            FileStream Img1 = new FileStream (imge_file[1], FileMode.Open);            FileStream Img2 = new FileStream (imge_file[2], FileMode.Open);            FileStream Img3 = new FileStream (imge_file[3], FileMode.Open);            FileStream Img4 = new FileStream (imge_file[4], FileMode.Open);            FileStream Img5 = new FileStream (imge_file[5], FileMode.Open); FileStream Img6 = new FileStream (imge_file[6], filemodE.open);            FileStream Img7 = new FileStream (imge_file[7], FileMode.Open);            FileStream Img8 = new FileStream (imge_file[8], FileMode.Open);            FileStream Img9 = new FileStream (imge_file[9], FileMode.Open);            int length0 = (int) img0.length;            byte[] Buffer0 = new Byte[length0];            Img0.read (Buffer0, 0, Length0);            String img_str0 = Convert.tobase64string (BUFFER0);            The picture is written in a string, the same as int length1 = (int) img1.length;            byte[] Buffer1 = new BYTE[LENGTH1];            Img1.read (buffer1, 0, length1);            String img_str1 = Convert.tobase64string (buffer1);            int length2 = (int) img2.length;            byte[] Buffer2 = new Byte[length2];            Img2.read (buffer2, 0, length2);            String img_str2 = Convert.tobase64string (buffer2);            int length3 = (int) img3.length;            byte[] Buffer3 = new BYTE[LENGTH3];            Img3.read (buffer3, 0, Length3); String IMG_STR3 = convert.tobase64string (Buffer3);            int length4 = (int) img4.length;            byte[] Buffer4 = new BYTE[LENGTH4];            Img4.read (buffer4, 0, Length4);            String IMG_STR4 = Convert.tobase64string (BUFFER4);            int length5 = (int) img5.length;            byte[] Buffer5 = new BYTE[LENGTH5];            Img5.read (buffer5, 0, Length5);            String IMG_STR5 = Convert.tobase64string (BUFFER5);            int length6 = (int) img6.length;            byte[] Buffer6 = new BYTE[LENGTH6];            Img6.read (BUFFER6, 0, Length6);            String IMG_STR6 = Convert.tobase64string (BUFFER6);            int length7 = (int) img7.length;            byte[] Buffer7 = new Byte[length7];            Img7.read (buffer7, 0, Length7);            String img_str7 = Convert.tobase64string (Buffer7);            int length8 = (int) img8.length;            byte[] Buffer8 = new Byte[length8];            Img8.read (Buffer8, 0, Length8); String img_str8 = Convert.toBase64string (Buffer8);            int length9 = (int) img9.length;            byte[] Buffer9 = new BYTE[LENGTH9];            Img9.read (Buffer9, 0, LENGTH9);            String IMG_STR9 = Convert.tobase64string (BUFFER9);            String img_total;            Img_total = IMG_STR0;            Console.WriteLine (Img_total.length); Img_total + = ".            ";            Console.WriteLine (Img_total.length);            Img_total + = IMG_STR1;            Console.WriteLine (Img_total.length); Img_total + = ". "+ Img_str2 +". "+ Img_str3 +". "+ IMG_STR4 +". "+ img_str5+". "+ IMG_STR6 +". "+ IMG_STR7 +". "+ Img_str8 +".            "+ Img_str9;            Console.WriteLine (Img_total.length); The split-string stream is 10 pictures, and the delimiter is '. ' string[] IMGs = Img_total.split ('.                        '); int length_new0 = imgs[5].            Length;            byte[] New0 = new Byte[length_new0];            New0 = convert.frombase64string (imgs[5]); Test code int length_test = img_str9.length;           byte[] Test = new Byte[length_test];                        Test = convert.frombase64string (IMG_STR9);            FileStream newimg = new FileStream ("E:/newimage.jpg", FileMode.Create);            FileStream newimg_buf = new FileStream ("E:/newimage_buf.jpg", FileMode.Create);            Newimg.write (Test, 0, test.length); Newimg_buf.            Write (New0, 0, new0.length);            Newimg.close (); Newimg_buf.            Close ();            Img0.close ();        Console.readkey (); }    }}

=============================================================================================================== ============

Pending Pictures:


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++

Experiment:



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Result picture path:



"C #" multiple pictures are written to string strings, separating the storage

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.