How to delete a file at a remote web location.

J

JohnSouth

Hi

I've a C# windows application that scans for XML files at a remote URL
address and downloads them to the local machine when they arrive. I
can do that OK with HttpWebRequest or WebClient.

After they've been downloaded I want to delete them from the remote
location (or if not possible, move or rename them). I can't see how to
do it.

Advice or ideas would be much appreciated.

John South
Pangbourne UK
www.wherecanwego.com
 
M

Marc Gravell

I would probably write a simple web-page (ashx or asmx depending on what is
calling it) that accepts a reference to the file (in the post for ashx or in
the arguments for asmx) (along with whatever security / authentication info
you need), and then the web-server can delete it's own file (locally) by
resolving the reference to a physical file (MapPath perhaps). I would also
rig the new page to *ONLY* delete files e.g. under a certain path (and
exclude anything containing ".." or starting with "/" or "~/") to prevent
incorrect (or just evil) usage from wiping the web-server.

Marc
 
J

JohnSouth

Hi Marc

I've got this working using a .ashx file to do the File.Delete but now
I'm installing it on a test system I'm struggling with the security
set-up. Can you give any clues on how to specify the user account that
the ashx file will use and how to give that account the rights to
delete a file.

I thought I understood this but obviously not.

Thanks

John South
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top