Recently, I lost all the images for my website due to some technical issues. All the images were also being saved in a SQLite database with the description as the file name. Instead of writing a brand new console app, I fired up LINQPad, added the SQLite driver and saved myself an hour's time
var images = (from img in ImageTables where img.Description.StartsWith("images") select img);
foreach (var img in images) {
var fi = new FileInfo(img.Description);
fi.Directory.Create();
File.WriteAllBytes(fi.FullName, img.Image);
img.Description.Dump();
}
Wednesday, April 13, 2011
Subscribe to:
Posts (Atom)