0
如何使用正則表達式或Raptorious.SharpMt940Lib解析mt940文件而不出錯?如何使用正則表達式或Raptorious.SharpMt940Lib解析mt940文件?
下面的代碼返回給我的錯誤:
var header = new Raptorious.SharpMt940Lib.Mt940Format.Separator("STARTUMSE");
var trailer = new Raptorious.SharpMt940Lib.Mt940Format.Separator("-");
var genericFomat = new Raptorious.SharpMt940Lib.Mt940Format.GenericFormat(header, trailer);
using (var fileStream = new FileStream(@"C:\test\ex.txt", FileMode.Open, FileAccess.Read))
{
TextReader tr = new StreamReader(fileStream);
var parsed = Raptorious.SharpMt940Lib.Mt940Parser.Parse(genericFomat, tr);
}
錯誤:
An unhandled exception of type 'System.IO.InvalidDataException' occurred in Raptorious.SharpMt940Lib.dll
Additional information: Can not find trailer!
示例數據:
:20:6307396651830602
:25:0010-01941/63073966-5183
:28C:00578/001
:60F:C155602TRY2683629,41
:61:1606055Y4774,04NERRNONREF
:86:GOND: HARRAN MAL.OD.HES20160602/201600000003267 S.GN.EMR OKUL 490
5631 NOLU ABONENIN ELEKTRIK TUKETIM BEDELI
:61:160602CY591,20NEFRRONREF
:86:GOND: BIRECIK MA.OD.HES20160602/201600000003244 S.GN.EMR AYggN CP
AL 4914861 NOLU ELEKTRIK ABONESININ FATURA ODEMESI
:61:160602CY2188,54NERRNONREF
我認爲錯誤消息是相當明顯的。您的庫正在查找指定消息結尾的字符串(您指定爲' - '),並且它在示例數據中找不到它。根據http://martin.hinner.info/bankconvert/swift_mt940_942.pdf,您的示例數據看起來不像標準mt940。 – villecoder