-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Soni
Message 1 in Discussion

Hi,
I'm looping through folders and files and adding them to a datatable.
This gives me the following OutOfMemoryException at times.   Error Exception of 
type 'System.OutOfMemoryException' was thrown.
----------- Error    at System.Data.RBTree`1.TreePage..ctor(Int32 size)
   at System.Data.RBTree`1.AllocPage(Int32 size)
   at System.Data.RBTree`1.GetNewNode(K key)
   at System.Data.RBTree`1.Insert(K item)
   at System.Data.Index.InitRecords(IFilter filter)
   at System.Data.Index..ctor(DataTable table, Int32[] ndexDesc, IndexField[] 
indexFields, DataViewRowState recordStates, IFilter
rowFilter)
   at System.Data.DataTable.GetIndex(IndexField[] indexDesc, DataViewRowState 
recordStates, IFilter rowFilter)
   at System.Data.DataTable.LoadDataRow(Object[] values, LoadOption
loadOption)   The code is as follows. THis code is executed for each file that 
is found. We are basically calulating the extensions and the size of the files 
wth similar extensions. The number of files are huge crossing 1,00,000 easily   
 private void AddExtInfo(FileInfo objFileInfo, string strRootPath)
        {
string strExpr = "Ext = '" + objFileInfo.Extension.Replace("'","''") + "'";
            DataRow[] drResult;
            drResult = dtDirInfoExt.Select(strExpr);
if (drResult.Length > 0)
            {
 object[] newRow1 = new object[4];
                newRow1[0] = drResult[0][0];
                newRow1[1] = drResult[0][1];
                newRow1[2] = Convert.ToInt32(drResult[0][2]) + 1;
                newRow1[3] = Convert.ToDouble(drResult[0][3]) + 
objFileInfo.Length;
                dtDirInfoExt.BeginLoadData();
                dtDirInfoExt.LoadDataRow(newRow1, LoadOption.OverwriteChanges);
                dtDirInfoExt.EndLoadData();
 }
            else
            {
                newRow = dtDirInfoExt.NewRow();
                newRow[0] = strRootPath;
                newRow[1] = objFileInfo.Extension;
                newRow[2] = 1;
                newRow[3] = objFileInfo.Length;
                dtDirInfoExt.Rows.Add(newRow);
               
            } any help will be highly appreciated.. Soni

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to