Click here to Skip to main content
13,201,940 members (72,978 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Heey all

i am creating a system for for a webshop

and i have run into a little problem

i am using a detailsview to see my products

and now i need to delete a Product, the question is how do i delete the Image that are in a folder on my server??

my database look like:

ProductID
ProductName
ProductDesc
ProductPrice
ProductImage

"ProductImage" has the FilePath and ImageName to the image
Posted 29-Jan-13 1:22am
Updated 29-Jan-13 2:38am
v3
Comments
source.compiler 29-Jan-13 9:35am
   
you want delete a file that ProductImage has its adress?
you can do it with system.io.file.delete then clear the productimage with a ado.net connecting!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

string path = "E:\\sasi\\delt.doc";
        FileInfo myfileinf = new FileInfo(path);
        myfileinf.Delete();



Make sure the ASP user has permissions to this folder. By default this user is not given access to much of the harddrive..
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Use NameSpace: using System.IO;


File.Delete(Server.MapPath("~/ProductImage/" + ProductImage));


Remember: Product Image should be in format : image.jpg......
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

if (System.IO.File.Exists(@"C:\test.txt"))
    System.IO.File.Delete(@"C:\test.txt"));


Try this
  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 |
Web04 | 2.8.171020.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2017
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