VintaSoft Twain .NET SDK v10.2
In This Topic
    How to select device without displaying the device selection dialog?
    In This Topic

    Example: Here is an example that shows how to select device by name.

    ''' <summary>
    ''' Select the device by the device name.
    ''' </summary>
    Public Sub SelectDeviceByName(ByVal deviceManager As Vintasoft.Twain.DeviceManager, ByVal deviceName As String)
        ' open TWAIN device manager
        deviceManager.Open()
    
        ' select the device by device name
        Dim device As Vintasoft.Twain.Device = deviceManager.Devices.Find(deviceName)
        ' if device is not found
        If device Is Nothing Then
            ' throw exception
            Throw New Exception("Device is not found.")
        End If
    
        ' acquire images asynchronously
        device.Acquire()
    End Sub
                  
    
    /// <summary>
    /// Select the device by the device name.
    /// </summary>
    public void SelectDeviceByName(Vintasoft.Twain.DeviceManager deviceManager, string deviceName)
    {
        // open TWAIN device manager
        deviceManager.Open();
    
        // select the device by device name
        Vintasoft.Twain.Device device = deviceManager.Devices.Find(deviceName);
        // if device is not found
        if (device == null)
            // throw exception
            throw new Exception("Device is not found.");
    
        // acquire images asynchronously
        device.Acquire();
    }