TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepak Sharma
NA
143
11.3k
Deleting photos from Gallary
Mar 8 2017 5:07 AM
Hi,
I am facing problem while deleting a photos from gallary.
I have created a gallary and there is a option for upload images in particular path not in a database.and i want option for select and delete photos.
Coading of upload option and delete option
protected void Page_Load(object sender, EventArgs e)
{
uploadimage();
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileName = FileUpload1.FileName;
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Images/" + fileName));
}
Response.Redirect("~/Upload.aspx");
}
private void uploadimage()
{
foreach (string strFileName in Directory.GetFiles(Server.MapPath("~/Images/")))
{
ImageButton imageButton = new ImageButton();
FileInfo fileInfo = new FileInfo(strFileName);
imageButton.ImageUrl = "~/Images/" + fileInfo.Name;
imageButton.Width = Unit.Pixel(100);
imageButton.Height = Unit.Pixel(100);
imageButton.Style.Add("Padding", "10px");
imageButton.Click += new ImageClickEventHandler(imageButton_Click);
Panel1.Controls.Add(imageButton);
}
}
void imageButton_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("~/Photosview.aspx?ImageURL=" + ((ImageButton)sender).ImageUrl);
}
protected void Button2_Click(object sender, EventArgs e)
{
string path = Server.MapPath(@"Images\");
string imgurl = path + "/Images/a.jpg";
try
{
FileInfo TheFile = new FileInfo(imgurl);
if (TheFile.Exists)
{
File.Delete(imgurl);
}
else
{
Bitmap bmp = new Bitmap(2, 2);
bmp.Save(imgurl, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
}
Label1.Text = "Success";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
Reply
Answers (
2
)
How to generate random username and password to textbox?
How to close transaction by by pass value using linq c#