this methode convert single tiff to 32 jpeg images
void IMAGE(string strFilePath)
{
string PathForCopy = string.Empty;
string folderName = string.Empty;
string TeacherId = string.Empty;
string directoryPath = string.Empty;
TeacherId = Convert.ToString(Session["TeacherId"]);
Bitmap bmap = null;
Session["UrlListForHe"] = null;
try
{
List<system.drawing.image> lst = new List<system.drawing.image>();
if (strFilePath != string.Empty)
{
string strFilename = System.IO.Path.GetFileNameWithoutExtension(strFilePath);
if (strFilename != "")
{
string strpagename = string.Empty;
if (File.Exists(strFilePath))
{
bmap = (Bitmap)System.Drawing.Image.FromFile(strFilePath);
int max = bmap.GetFrameCount(FrameDimension.Page);
float icount = (float)100 / max;
folderName = ConfigurationManager.AppSettings["FolderToViewPagesForEvaluator"].ToString();
PathForCopy = folderName + TeacherId;
if (!Directory.Exists(Server.MapPath(PathForCopy)))
{
Directory.CreateDirectory(Server.MapPath(PathForCopy));
}
int i;
for (i = 0; i < max; i++)
{
bmap.SelectActiveFrame(FrameDimension.Page, i);
strpagename = strFilename + "Page" + i.ToString().Trim();
lst.Add((System.Drawing.Image)bmap.Clone());
string url = Server.MapPath(PathForCopy) + "/00" + i.ToString() + ".Jpeg";
string Imgurl = PathForCopy + "/00" + i.ToString() + ".Jpeg";
(lst[i] as System.Drawing.Image).Save(url, ImageFormat.Jpeg);
strpath.Add(Imgurl);
}
Session["UrlListForHe"] = strpath;
lblPageCount.Text = strpath.Count().ToString();
TextBox1.Text = "1";
Image1.ImageUrl = strpath[0].ToString() + "?" + DateTime.Now.Ticks.ToString() ;
btnpre.Enabled = false;
btnnext.Enabled = true;
bmap.Dispose();
}
else
{
btnpre.Enabled = false;
btnnext.Enabled = false;
TextBox1.Text = "0";
lblPageCount.Text = "";
Image1.ImageUrl = "~/Images/FileNotFound.png";
bmap.Dispose();
}
}
else
{
btnpre.Enabled = false;
btnnext.Enabled = false;
TextBox1.Text = "0";
lblPageCount.Text = "";
Image1.ImageUrl = "~/Images/FileNotFound.png";
bmap.Dispose();
}
}
}
methode for deleting tiff image
public bool DeleteMarksAndCopyForRecheck(string roll, string subject, string bar,string path,out string msg)
{
bool flag = false;
msg = string.Empty;
string str = "exec SetIsEvaluatedZero " + roll + " , '" + subject + "' , '" + bar + "'";
path = HttpContext.Current.Server.MapPath(path);
string ReplacePathForPopUp = ConfigurationManager.AppSettings["ReplacePathForCopyRecheckPopUp"];
string Newpath = path.Replace(ReplacePathForPopUp, "");
try
{
if (System.IO.File.Exists(Newpath))
{
File.Delete(Newpath);
if (!(System.IO.File.Exists(Newpath)))
{
dt = ClsConObj.ExecuteProcedureREturnTable(str);
if (dt.Rows[0]["msg"].ToString().Trim() == "YES".Trim())
{
flag = true;
msg = "D";
}
else
{
flag = false;
msg = "B";
}
}
}
else
{
flag = false;
msg = "A";
}
}
catch (Exception ex)
{
flag = false;
msg = "C";
}
return flag;
}