17,740
社区成员
发帖
与我相关
我的任务
分享
try
{
CameraCaptureDialog camera = new CameraCaptureDialog();
camera.Owner = new Control();
camera.Title = "test";
camera.Mode = CameraCaptureMode.Still;
camera.StillQuality = CameraCaptureStillQuality.High;
camera.Resolution = new Size(100, 100);
string path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName) + "\\Photo\\";
if (!File.Exists(path))
{
Directory.CreateDirectory(path);
}
camera.InitialDirectory = path;
camera.DefaultFileName = "test_photo";
if (camera.ShowDialog() == DialogResult.OK)
{
photoPath = camera.FileName;
}
}
catch (Exception Err)
{
MessageBox.Show("调用照相机出错,请重试" + Err.Message);
}