这是用于使用C#编写的Windows 10的通用Windows平台(UWP)应用程序,其目的是使用以下类扫描文档:
Windows.Devices.Scanners.ImageScanner
在线:
// Scan API call to start scanning from the Feeder source of the scanner.
ImageScannerScanResult isr = await myScanner.ScanFilesToFolderAsync(ImageScannerScanSource.Feeder, folder);
我得到以下异常:
System.Exception: Exception from HRESULT: 0xE8E2DD73
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MyProject.ScannerPage.<ScanToFolder>d__11.MoveNext()
这个异常是随机抛出的:有时候,我说的代码行成功运行,有时它失败了,我还没有检测到导致它失败的模式或条件。
我得到的唯一提示是&#34; HRESULT:0xE8E2DD73&#34; (在其他计算机中,HRESULT代码是:0x904427B5),但我一直无法找到该HRESULT代码的含义。
所以,我想知道你们是否有解决这个问题的方法或者采用不同的方法来执行这个操作。
这是完整的代码:
try
{
// Get the scanner object for this device id
ImageScanner myScanner = await ImageScanner.FromIdAsync(deviceId);
// Check to see if the use has already cancelled the scenario
if (model.ScenarioRunning)
{
if (myScanner.IsScanSourceSupported(ImageScannerScanSource.Feeder))
{
// Set MaxNumberOfPages to zero to scanning all the pages that are present in the feeder
myScanner.FeederConfiguration.MaxNumberOfPages = 0;
cancellationToken = new CancellationTokenSource();
// Scan API call to start scanning from the Feeder source of the scanner.
ImageScannerScanResult operation = await myScanner.ScanFilesToFolderAsync(ImageScannerScanSource.Feeder, folder);
model.ScenarioRunning = false;
}
else
{
// The selected scanner does not have a Feeder
model.ScenarioRunning = false;
}
}
}
catch (Exception ex)
{
Utils.OnScenarioException(ex, model);
}