我扫描了3张图片,但只保存了最后一张图片。关于我遗失或做错的任何建议......谢谢。
string ScanData;
using (Stream receiveStream = Request.InputStream)
{
using (StreamReader readStream = new StreamReader(Request.InputStream, Encoding.UTF8))
{
ScanData = readStream.ReadToEnd();
}
}
IEnumerable x = Convert.FromBase64String(ScanData.Replace("data:;base64,", String.Empty));
byte[][] datain = x.OfType<byte[]>().ToArray();
foreach (var data in datain)
{
int counter = 0;
System.IO.File.WriteAllBytes(@"C:\\" + DateTime.Now.ToString("MM-dd-yyyy") + "-" + counter++ + ".check", data);
//3 items get scanned and only the last item is saved... help?!
}
这是我的原始代码,我尝试添加byte [] []以查看它是否有帮助。 我只收到一张图片,当发送3张图片时。
string ScanData;
using (Stream receiveStream = Request.InputStream)
{
using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
{
ScanData = readStream.ReadToEnd();
}
}
try
{
byte[] data = Convert.FromBase64String(ScanData.Replace("data:;base64,", String.Empty));
System.IO.File.WriteAllBytes(@"C:\\" + DateTime.Now.ToString("MM-dd-yyyy") + "-" + counter++ + ".check", data);
}
catch (Exception e)
{
throw new Exception("Error: " + e.Message);
}