I'm looking to get an estimate of the size of the data that is contained in DataTable in MB. I've to loop through each row and Marshal.SizeOf() but at runtime I get an error that
Type 'System.String' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.
here is a sample of the code I'm using to get the size:
private static int dsSize(DataSet ds)
{
int returnValue = 0;
foreach (DataRow dr in ds.Tables[ds.Tables.Count - 1].Rows)
{
int rowSize = 0;
for (int i = 0; i < ds.Tables[ds.Tables.Count - 1].Columns.Count; i++)
{
rowSize += System.Runtime.InteropServices.Marshal.SizeOf(dr[i]);
}
returnValue += rowSize;
}
return returnValue;
}
any ideas as to how to achieve getting the size of data?
thanks in advance