我创建了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);
}
}
我用你的代码,但在这里的路径是有必要提供图像fil.for例如“D:\\ scanning image \\ lelo.jpg”的名称我只是想给出的名称这里是扫描图像的文件夹。我希望lelo.jpg在保存时由用户输入....你可以为我分享完整的代码。 –