Click here to Skip to main content
12,299,086 members (49,044 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
There is a List view for images in my .aspx page, I want to delete selected image from the folder without using database as my site is static and i have not used database, how can i delete selected image from the folder? please help.
Posted 26-Mar-13 21:12pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Do something like this :-

string FileName ="test.txt";
string Path = "E:\\" + FileName;
FileInfo file = new FileInfo(Path);
if (file.Exists)
{
  file.Delete();
}

Get your file name from listview and then find the path then delete.
And do remember to include using System.IO; namespace.
So simple Isn't it?

Or

File.Delete(Server.MapPath(@"Images\SomeImage.png"));

here you can get your image name from list view.

Happy Holi.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

datatable dt=selecet postid from postdetails

var a= dt.rows.count;

var i;
for(I=0;I<a;i++)>
{
datatable dt1=select imagepath from image where postid=dt[i][0]
var b=dt1.rows.count;
for(j=0;j<b;j++)>
{
var temp=dt1[j][0];
dlete(temp);
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 17 Apr 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100