// FILE OR IMAGE DELETION AND CREATION ( Use for delete the Image) (UPDATING
// THE PREVIOUS FILE using c#.net , asp.net
using System.Drawing;
using System.IO;
public void filedel()
{
string path = Server.MapPath(@"images\");
string imgurl = path + "a.jpg";
try
{
FileInfo TheFile = new FileInfo(imgurl);
if (TheFile.Exists)
{
File.Delete(imgurl); // It not works if file is used in another process
}
else
{
// File.Create(imgurl);
//or
// Code To Create image
Bitmap bmp = new Bitmap(2, 2);
bmp.Save(imgurl, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
}
Label1.Text = "Sucess";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
// THE PREVIOUS FILE using c#.net , asp.net
using System.Drawing;
using System.IO;
public void filedel()
{
string path = Server.MapPath(@"images\");
string imgurl = path + "a.jpg";
try
{
FileInfo TheFile = new FileInfo(imgurl);
if (TheFile.Exists)
{
File.Delete(imgurl); // It not works if file is used in another process
}
else
{
// File.Create(imgurl);
//or
// Code To Create image
Bitmap bmp = new Bitmap(2, 2);
bmp.Save(imgurl, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
}
Label1.Text = "Sucess";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
No comments:
Post a Comment