2017/01/22

[C#]檔案轉為 byte[]

先引用 using System.IO; 
//WebService WCF 提供的服務協助轉為byte[]
System.Net.WebClient wc = new System.Net.WebClient();
byte[] bytes = wc.DownloadData(FilePath);

//WebService
WCF 提供服務部分
using (FileStream fs = new FileStream(fileFullName, FileMode.Open, FileAccess.Read))
using (BinaryReader br = new BinaryReader(fs))
return br.ReadBytes(Convert.ToInt32(fs.Length));

沒有留言: