public static void SetBytes(string resName, int recordId, byte[] data) { RecordStore rs = null; try { rs = RecordStore.OpenRecordStore(resName, true); if (rs.GetNumRecords() == 0) { rs.AddRecord(data, 0, data.Length); } else { rs.SetRecord(recordId, data, 0, data.Length); } } catch (RecordStoreException ex) { Log.Exception(ex); } finally { CloseRecordStore(rs); } }
public static void RemoveRecord(string resName, int recordId) { RecordStore rs = null; try { rs = RecordStore.OpenRecordStore(resName, false); rs.DeleteRecord(recordId); } finally { CloseRecordStore(rs); } }
public static bool ExistRecordStore(string resName) { RecordStore rs = null; try { rs = RecordStore.OpenRecordStore(resName, false); return(rs != null); } catch { return(false); } finally { CloseRecordStore(rs); } }
public static int AddBytes(string resName, byte[] data) { RecordStore rs = null; bool opened = false; try { rs = RecordStore.OpenRecordStore(resName, true); opened = true; return(rs.AddRecord(data, 0, data.Length)); } catch (RecordStoreException ex) { Log.Exception(ex); } finally { CloseRecordStore(rs); } return(opened ? COULD_NOT_SAVE : COULD_NOT_OPEN); }
public static byte[] GetBytes(string resName, int recordId) { byte[] result = new byte[0]; RecordStore rs = null; try { rs = RecordStore.OpenRecordStore(resName, true); if (rs.Count >= recordId) { result = rs.GetRecord(recordId); } } catch (Exception ex) { Log.Exception(ex.Message); } finally { CloseRecordStore(rs); } return(result); }