【发布时间】:2013-03-17 21:19:03
【问题描述】:
大家好,我正在尝试保存从我的网络摄像头拍摄的照片。 我实际上正在使用此代码
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/resources/38150-Capture-save-images-from-Web-camera.aspx(查看附件)
【问题讨论】:
-
你遇到了什么错误?
-
@Emmanuel N 没有错误,伙计....它运行良好但我无法获得应保存在 C:\\Webcam.jpg 的图像
-
哦,伙计们,我得到了解决方案:\你只是不把它保存在驱动器 C 上:更改保存路径,我会很好 @Emmanuel N thks fr ur 关注兄弟。