I am trying to control size of my picture to do not be more than 200 KB
how can I do this
Assume that I want to choose picture with FileUpload from my PC and before uploaded the Image check the size.
string stream = FileUpload1.FileName;
string sub = stream.Substring(stream.LastIndexOf(".") + 1);
FileInfo fileinfo = new FileInfo(Server.MapPath(stream.ToString()));
if (FileUpload1.HasFile)
{
if (sub == "jpg" || sub == "jpeg" || sub == "png")
{
if ((fileinfo.Length / 1024) <= 200)
{
string path = Server.MapPath("~/Image/" + stream);
Image1.ImageUrl = path;
FileUpload1.SaveAs(path);
//Image1.DataBind();
Label1.Text = fileinfo.Length.ToString();
}
else
{
Label1.Text = "Please insert valid Image";
}
}
else
{
Label1.Text = "Please insert valid Image";
}
}
With this code I'm getting
error is the file not found