Home All Groups Group Topic Archive Search About

File uploaded to server....How can I delete it?

Author
22 May 2005 12:34 PM
daiski
Hi,

I have uploaded an image to the web server using the code below. Note
that 'FileUpload' is the name of my HTML input control.

if (FileUpload.PostedFile != null)
{
   String virtualPath = "~/uploads/" + Path.GetFileName
(FileUpload.PostedFile.FileName);
   String phyiscalPath = Server.MapPath(virtualPath);
   FileUpload.PostedFile.SaveAs(phyiscalPath);
}

I save the physicalPath and virtualPath in SQL DB for image retrieval.

QUESTION:  How can I delete the image 'physically' from the web server
if I dont need it any more??

Author
23 May 2005 12:56 PM
Brock Allen
System.IO.File.Delete

-Brock
DevelopMentor
http://staff.develop.com/ballen



Show quoteHide quote
> Hi,
>
> I have uploaded an image to the web server using the code below. Note
> that 'FileUpload' is the name of my HTML input control.
>
> if (FileUpload.PostedFile != null)
> {
> String virtualPath = "~/uploads/" + Path.GetFileName
> (FileUpload.PostedFile.FileName);
> String phyiscalPath = Server.MapPath(virtualPath);
> FileUpload.PostedFile.SaveAs(phyiscalPath);
> }
> I save the physicalPath and virtualPath in SQL DB for image retrieval.
>
> QUESTION:  How can I delete the image 'physically' from the web server
> if I dont need it any more??
>