Click here to Skip to main content
11,635,656 members (78,593 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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
Edited 29-Jan-13 2:38am
v3
Comments
source.compiler at 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
0 OriginalGriff 8,861
1 Sergey Alexandrovich Kryukov 8,459
2 Mika Wendelius 6,849
3 F-ES Sitecore 2,354
4 Suvendu Shekhar Giri 2,270


Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2015
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