首页 > 解决方案 > 从 Access 数据库的 BLOB 字段中提取信息

问题描述

我一直在使用一个名为 myphotoindex 的旧照片标记程序,并想提取我多年来创建的所有照片标记。该程序是用 C# 编写的(我从未使用过)并使用 Access 数据库。我对javascript更满意。我试图将 Access 中的数据导出到 XML 文件中,它看起来像 Base64 信息。从下面的 C# 代码中,标签看起来像是序列化的数组。如果可能的话,我只想要纯文本的数组信息。非常感谢任何不涉及 C# 编程的帮助。

if ((reader.IsDBNull(((int)(ImageDataSourceColumnId.ImageTags))) == false)) {
    byte[] byteArray = new byte[reader.GetBytes(((int)(ImageDataSourceColumnId.ImageTags)), 0, null, 0, Int32.MaxValue)];
    if (((byteArray != null) 
                && (byteArray.Length > 0))) {
        reader.GetBytes(((int)(ImageDataSourceColumnId.ImageTags)), 0, byteArray, 0, byteArray.Length);
        MemoryStream ms = new MemoryStream(byteArray);
        BinaryFormatter bf = new BinaryFormatter();
        try {
            object intArrray = bf.Deserialize(ms);
            imageData.AddTags(((int[])(intArrray)));
        }
        catch (ArgumentNullException ex) {
            Logger.Log(ex);
            imageData.ClearTags();
        }
        catch (SerializationException ex) {
            Logger.Log(ex);
            imageData.ClearTags();
        }
        catch (SecurityException ex) {
            Logger.Log(ex);
            imageData.ClearTags();
        }
        
    }
    
}

标签: c#blob

解决方案


推荐阅读