最近利用ImemoryBlobStream做二进制流文件的读入写出,这个接口用起来很简单,还是直接贴代码直观。
public static bool FileToBlob(IFeature pFeature,string FileName)
{
try
{
IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();
pMemoryBlobStream.LoadFromFile(FileName);
int Index = pFeature.Fields.FindField("BlobFile");
pFeature.set_Value(Index, pMemoryBlobStream);
pFeature.Store();
return true;
}
catch
{
return false;
}
}
public static bool BlobToFile(string FilePath, IFeature pFeature)
{
try
{
int Index = pFeature.Fields.FindField("BlobFile");
if (pFeature.get_Value(Index) != null)
{
IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();
pMemoryBlobStream = (IMemoryBlobStream)pFeature.get_Value(Index);
pMemoryBlobStream.SaveToFile(FilePath);
return true;
}
else return false;
}
catch
{
return false;
}
}