Click here to Skip to main content
Rate this: bad
good
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

1 solution

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

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

  Print Answers RSS
0 OriginalGriff 449
1 ChintanShukla 305
2 Sergey Alexandrovich Kryukov 293
3 RyanDev 250
4 Richard Deeming 250
0 Sergey Alexandrovich Kryukov 8,901
1 OriginalGriff 7,571
2 CPallini 2,603
3 Richard MacCutchan 2,095
4 Abhinav S 1,893


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 27 Mar 2013
Copyright © CodeProject, 1999-2014
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