大家好,我正在尝试保存从我的网络摄像头拍摄的照片。我实际上使用这段代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CreatePhoto();
}
void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);
FileStream fs = new FileStream("C:\\Webcam.jpg", FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();
}
catch (Exception Ex)
{
}
}
}
应用程序运行,我看到图像,我单击捕获按钮它没有给出任何错误,直到这里但是但是......没有图像被保存我从这里下载了示例:http: //www.dotnetspider.com/资源/38150-Capture-save-images-from-Web-camera.aspx (检查附件)