我创建了一个 Windows 窗体应用程序来扫描任何图像。
扫描完成后,它会要求用户将其保存在任何文件夹中,但我希望将图像保存在特定文件夹中。
我使用的代码:
public class Scanner
{
Device oDevice;
Item oItem;
CommonDialogClass dlg;
public Scanner()
{
dlg = new CommonDialogClass();
oDevice = dlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, true, false);
}
public void Scann()
{
try
{
dlg.ShowAcquisitionWizard(oDevice);
}
catch (NullReferenceException ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void button1_Click(object sender, EventArgs e)
{
Scanner oScanner = new Scanner();
oScanner.Scann();
//Saving the image to the server directly
button1.Text = "Image scanned";
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(dlg.FileName);
}
}