c# - Save single column datatable to disk fast -


i've got save datatable disk. single column , i've been looping round saving each row, , i've tried adding rows string , saving that.

 = 0 dt.rows.count - 1  fd.savefile("c:\filename.txt, " " & dt.rows(i).item("word"), "append")   'appends file  'or  wordlist = wordlist & " " & dt.rows(i).item("word")  'builds word list and..  next  '  fd.savefile("c:\filename.txt", "overwrite") 'then saves disk. 

it slow.

i've found this:

http://bytes.com/topic/c-sharp/answers/250808-storing-datatable-data-hard-disk

filestream fs = new filestream(@"c:\test.bin", filemode.create); binaryformatter bf = new binaryformatter(); bf.serialize(fs, dt); fs.close(); 

that whacks out serialized version of data in super quick time. faster looping processes. how can dump datatable that, no meta-data? doesn't need read datatable. serialize method puts etc tags everywhere.

don't reopen file each row. either keep writng same stream or write @ once 1 of file helper methods file.writealllines:

file.writealllines(@"c:\filename.txt",      dt.rows.oftype<datarow>().select(r => r.item("word")); 

Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -