2014-02-05 40 views
-1

我正在創建一個程序,它將圖像轉換爲二進制數據並將其存儲在txt文件中,並將txt文件發送給另一個人。其他人將從中選擇此文件openfiledialog框,然後將其轉換回image.So我堅持閱讀txt文件並將其存儲在一個字節[]文件,然後將其轉換爲圖像。從txt文件讀取二進制數據並存儲在字節數據類型

+0

您已經嘗試了什麼?給一些代碼 –

+0

你嘗試過什麼嗎?顯示一些努力==代碼.. – etaiso

+0

嗨,對不起,我是新來的C#,但已閱讀這從msdn,但只顯示在屏幕上,我怎麼能將它保存到字節文件http://msdn.microsoft.com/en -us/library/aa287535(v = vs.71).aspx – user3145883

回答

0

使用這個..

byte[] b = System.IO.File.ReadAllBytes("filepath"); 
System.IO.MemoryStream imgStream = new System.IO.MemoryStream(); 
imgStream.Write(b, 0, b.Length); 
System.Drawing.Image img; 
img = System.Drawing.Image.FromStream(imgStream); 
//use this image as Image of pictureBox 
相關問題