private void loadImages() { Console.WriteLine("loading images"); d.FileData fd = new d.FileData(); string[] files = Directory.GetFiles(TESTIMAGES_PATH); ba.ImageHelper ih = new ba.ImageHelper(); foreach (string f in files) { FileInfo fi = new FileInfo(f); int id = fd.Create(fi.Extension, getRandomText(5, 100), getRandomText(50, 500), 1); if (id > 0) //neccessary check: might have been duplicate titles, since it's a random generator { string imagePath = FILES_PATH + ba.UrlHelper.GetImageName(id, fi.Extension); string imageThumbPath = FILES_PATH + ba.UrlHelper.GetImageName(id, "s" + fi.Extension); ih.MakeImage(f, imagePath, 0, 0); ih.MakeImage(f, imageThumbPath, 100, 75); Bitmap im = new Bitmap(imagePath); d.File df = new d.File(id); df.Size = (int)fi.Length; df.ImageWidth = im.Width; df.ImageHeight = im.Height; df.Update(); im.Dispose(); } } }
private void loadFiles() { Console.WriteLine("loading files"); d.FileData fd = new d.FileData(); string[] files = Directory.GetFiles(TESTFILES_PATH); foreach (string f in files) { for (int i = 0; i < 50; i++) { FileInfo fi = new FileInfo(f); int id = fd.Create(fi.Extension, getRandomText(5, 100), getRandomText(50, 500), 1); if (id > 0) { string filePath = FILES_PATH + ba.UrlHelper.GetFileName(id, fi.Extension); File.Copy(f, filePath); d.File df = new d.File(id); df.Size = (int)fi.Length; df.Update(); } } } }