Geeks With Blogs
Rajiv Popat blog

While everyone seems to be talking about the Amazing and new Features of 2.0 like Membership, Generics, Code Snippets, Partial Classes... (the list continues), let me be the guy who blogs about a tiny little new function in 2.0 that will save a developer 1.5 minutes (give or take a minute) of development time and some 3 odd lines of code :).

For A Recent Project I had to extract BLOBS stored in DB and write them in the file system. Turns out, there is a cool file system function which just lets you write an entire byte array to disk!!

byte[] bFile = new byte[filesize];
bFile = (byte[])ds.Tables[0].Rows[nCounter]["FILE_DATA"];
System.IO.File.WriteAllBytes(fileURL, bFile);

The WriteAllBytes is an out of the box function that just takes the file path and name along with the byte arrary and just creates the file for you IF the directories specified in the path exist. I know this is not going to change the world but what the heck... it's kind cool! One lesser loop to write!

(Moved From http://rajivpopat.blogspot.com)

 

Posted on Thursday, January 19, 2006 2:59 PM Cookbooks And Articles | Back to top


Comments on this post: A Minute Saved...

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Rajiv Popat | Powered by: GeeksWithBlogs.net