Click here to Skip to main content
Sign Up to vote bad
good
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:22
Edited 29 Jan '13 - 2:38

Comments
source.compiler - 29 Jan '13 - 9:35
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!

3 solutions

Use NameSpace: using System.IO;
 
File.Delete(Server.MapPath("~/ProductImage/" + ProductImage));
 
Remember: Product Image should be in format : image.jpg......
  Permalink  
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  
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
Your Filters
Interested
Ignored
     
0 OriginalGriff 345
1 Sergey Alexandrovich Kryukov 338
2 Arun Vasu 315
3 Maciej Los 208
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,755
1 OriginalGriff 7,549
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid