Reputation: 747
I am trying to loop through jpeg images from a folder and feeding it to the dll using the below method but it throws me this error Source may only be an instance of string, VirtualFile, IVirtualBitmapFile, HttpPostedFile, HttpPostedFileBase, Bitmap, Image, or Stream. Parameter name: source
foreach(FileInfo file in tempFolder.GetFiles())
if (file.Exists == true)
{ //Skip unused file controls.
//The resizing settings can specify any of 30 commands.. See http://imageresizing.net for details.
//Destination paths can have variables like <guid> and <ext>, or
//even a santizied version of the original filename, like <filename:A-Za-z0-9>
ImageResizer.ImageJob i = new ImageResizer.ImageJob(file, uploadFolder + "/<guid>.<ext>", new ImageResizer.ResizeSettings(
"width=2000;height=2000;format=jpg;mode=max"));
i.CreateParentDirectory = true; //Auto-create the uploads directory.
i.Build();
}
browser.Attributes["multiple"] = "multiple";
Page.Response.Redirect(Page.Request.Url.ToString(), true);
}
Upvotes: 0
Views: 308
Reputation: 1097
ImageRsizer.ImageJob
accepts file path as parameter. Instead of providing FileInfo
object, you need to pass FullName
property of it. i.e.:
ImageResizer.ImageJob i = new ImageResizer.ImageJob(file.FullName, uploadFolder + "/<guid>.<ext>", new ImageResizer.ResizeSettings(
"width=2000;height=2000;format=jpg;mode=max"));
Upvotes: 2