This code will use Twain high level functions using LEADTOOLS .NET, this code will show you how to change the transfer options in an easy way, without having to go through setting the capabilities and modify their values.
LEADTOOLS .NET high level functions will deal with the capabilities internally and change their values and prepare the acquire process in a very easy way.
The following is the code:
// This function will acquire page and save it to file using file transfer mode
private void AcquireUsingFileMode(TwainSession session)
{
try
{
// check if file transfer mode is supported or not
if (session.IsFileTransferAvailable == false)
{
// the file transfer mode is not supported
MessageBox.Show(this, "File transfer mode is not supported!");
return;
}
// get the default transfer options
session.GetTransferOptions();
// set transfer mode to file
session.TransferMode = TwainTransferModes.TwainTransferFile;
// set transfer file format
session.TransferFileFormat = (int)TwainCapabilityValue.FileFormatBmp;
// set transfer file name, the file name will be used to save the acquired page
session.TransferFileName = @"c:\test.bmp";
// update transfer options
session.SetTransferOptions();
// Acquire the page from source and save it to file
session.Acquire(TwainUserInterfaceFlags.Show | TwainUserInterfaceFlags.Modal);
MessageBox.Show(this, "Acquired page is saved to file", "Acquire to File");
}
catch (Exception ex)
{
// failure occurred
MessageBox.Show(this, ex.Message);
}
}
Gabe
Developer Support
LEAD Technologies, Inc.
![LEAD Logo LEAD Logo](https://www.leadtools.com/images/new-site-images/leadtools-logo-header.png)