1、自动保存相片:指定路径保存C盘保存:

 String savePath = @"C:\";

string filename = $"{DateTime.Now:yyyyMMddHHmmss}.jpg";
 string filepath = savePath + filename;

// 拍照并保存图像

Bitmap image = TakePhoto();

image.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);

2、自动保存相片:当前运行目录下:

    string filename = $"{DateTime.Now:yyyyMMddHHmmss}.jpg";
     string filepath = Path.Combine(Environment.CurrentDirectory, filename);

// 拍照并保存图像

Bitmap image = TakePhoto();

image.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);

3、自动保存相片:桌面:

string filepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{DateTime.Now:yyyyMMddHHmmss}.jpg");

// 拍照并保存图像

Bitmap image = TakePhoto();

image.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);

4、手动保存相片:选择路径保存

saveFileDialog1.RestoreDirectory = true;
saveFileDialog1.FileName = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".jpg";

   // 已选择的文件路径
 string filepath= saveFileDialog1.FileName.ToString();

// 拍照并保存图像

Bitmap image = TakePhoto();

image.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg);

06-10 20:23