How to select scanner by its name?

Dynamic .NET TWAIN offers a method named SelectSourceByIndex which allows you to select the index - the source in SourceNameItems property as the current source.

However, in some cases, you may want to select the source by source name. There isn't such a method, but that can be achieved by a few lines of code.
Following is the sample code:

for(short i = 0; i < dynamicDotNetTwain1.SourceCount; i++)
    String PSourceName = "7500"; //"7500" is part of your source name
    if(dynamicDotNetTwain1.SourceNameItems(i).IndexOf(PSourceName) != -1)

In the sample, we use a scanner named HP Scanjet Enterprise 7500. So the PSourceName can be "7500".

You need to change the PSourceName accordingly. In order to select the right source as you wanted, make sure that the PSourceName is unique to all the source.

Is this page helpful?

Leave a Reply

Your email address will not be published.