Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I delete a .jpg from remote server using c#? 1

Status
Not open for further replies.

shaunacg

Programmer
Aug 1, 2003
71
GB
Hi,

I have a form where I use posted.filename to upload jpg images into the photos folder on the web site's server. On the same page I have a delete button. When an item is deleted I would like to then remove the .jpg from the photos folder on the remote server. Can I do this?

Thanks.
shaunacg
 
Yes, you can. Unfortunately, I code only in VB but you should be able to translate this without issue....

First assign the complete file name to a string variable (including path, etc.). Then use File.Delete:

strDelete = "C:\Pics\BadUnWanted.JPG"
If File.Exists(strDelete) Then
File.Delete(strDelete)
End If

HTH

Eva
 
You also have to make sure that the web servers' aspnet account has read/write access to the remote server. I'm assuming though, that seeing as how that's where you're uploading, you probably have already done that :)

Just had to point out the obvious.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top