Click here to Skip to main content
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 2:22am
Edited 29-Jan-13 3: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 274
1 Sergey Alexandrovich Kryukov 255
2 Shweta N Mishra 216
3 PIEBALDconsult 200
4 BillWoodruff 174
0 OriginalGriff 7,630
1 Sergey Alexandrovich Kryukov 7,022
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,525


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 29 Jan 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