如何在C#中读取微线

时间:2011-06-06 11:03:41

标签: c# windows

任何人都可以帮我解决c#

我扫描了一张支票,从中我想读取微线并从c#中的MICR线获取银行路由号码和支票号码的详细信息,我在Windows应用程序中工作

 public static string ReadOneMICR(string file, int page)
            {
                try
                {
                    string sout = "";
                    mut.WaitOne();      // Prevent reentrancy 
                    ClearMicr.CcMicrReader reader = new ClearMicr.CcMicrReader();
                    reader.Image.Open(file, page);
                    // Do actual reading  
                    reader.FindMICR();
                    // Display results 
                    if (reader.MicrCount > 0)
                    {
                        ClearMicr.CcMicr Micr = reader.get_MicrLine(1);
                        sout = sout + "MICR Type: " + Micr.DocumentType + Environment.NewLine;
                        if (Micr.Routing.IsRead)
                            sout = sout + "Routing = " + Micr.Routing.TextANSI + Environment.NewLine;
                        if (Micr.AuxOnUs.IsRead)
                            sout = sout + "AuxOnUs = " + Micr.AuxOnUs.TextANSI + Environment.NewLine;
                        if (Micr.OnUs.IsRead)
                            sout = sout + "OnUs = " + Micr.OnUs.TextANSI + Environment.NewLine;
                        if (Micr.Amount.IsRead)
                            sout = sout + "Amount = " + Micr.Amount.TextANSI + Environment.NewLine;
                        if (Micr.Account.IsRead)
                            sout = sout + "Account = " + Micr.Account.TextANSI + Environment.NewLine;
                        if (Micr.CheckNumber.IsRead)
                            sout = sout + "CheckNumber = " + Micr.CheckNumber.TextANSI + Environment.NewLine;
                    }
                    else
                        sout = "No MICR found";
                    return sout;
                }
                catch (Exception ex)
                {
                    return ("ERROR: " + ex.ToString());
                }
                finally
                {
                    mut.ReleaseMutex();
                    System.GC.Collect();
                }
            }

这里是示例代码,我面对get_MicrLine和TextANSI行的上述代码中的问题请澄清我,并提供一个无错误的代码,用于读取检查中的微线

1 个答案:

答案 0 :(得分:2)

您还没有说出您的错误,但您可以尝试使用此替换行:

ClearMicr.CcMicr Micr = reader.MicrLine[1];