Computer.FileSystem.DeleteFile not working over network

  • Thread starter Thread starter Julia B
  • Start date Start date
J

Julia B

Hi all

I've got an ASP.Net 2.0 web application, where users are uploading files to
the web server from a C drive on a networked pc.

The upload and save work fine, but once done, I want the original file on
the pc D drive to be deleted.

The code I'm using is:

My.Computer.FileSystem.DeleteFile(Me.newCalibrationRecord.RecordLocation)

Me.newCalibrationRecord.RecordLocation is "C:\DirectoryName\Filename".

I get an error message saying the file cannot be found despite the fact that
I know it's there. I've also checked permissions and the ASP.NET account has
the correct permissions to the pc's C drive.

Is it something to do with the fact that the application is looking on the
webserver's C drive not the user's local machine?

Thanks in advance
Julia
 
Hi,

Sure keep in mind that the web page runs ont he server so c: is the server
drive.

More generally what you want to do is not possible (you don't have access
out of the box to a user machine for safety reasons). If you are under a
controlled environment you could perhaps achiveve this (establishing shares
on your wokrstation or installing a client side tool to do that suc as a
ajava, activex or dotnet applet). The big picture could help to raise better
suggestion. What are trying to do ? Whay to delete the file once uploaded ?
(some kind of file repository system ??)
 
Hi Patrice

Thanks for the help. My users have requested that the file on the c drive be
deleted once uploaded to the web application. It's a file sorting/respositary
application and if the original file is deleted then it reduces their
workload.

Although we are on a large network, there is only one pc that will be using
this application so it only applies to the one pc. Would that help?

Julia
 
Because it's a company application and multiple users/machines will access it
to view information but there is only one machine that needs to upload
information to the system.

Julia
 
Mark Rae said:
[please don't top-post]
Because it's a company application and multiple users/machines will access
it
to view information but there is only one machine that needs to upload
information to the system.

Sounds like you need a WebForms app and WinForms app
Mark

Sorry about top posting, didn't know it was an issue.

Users have requested one application as, although only one pc will upload
documents, the users on that pc will also use all the other functions and
don't want to move between applications, so a web application has been
selected to be the best method for the whole thing.

With this in mind is there any way around this?

Thanks
Julia
 
Mark Rae said:
Top-posting means people have to read backwards any thread that you reply
to:
http://www.caliburn.nl/topposting.html



All modern browsers are specifically written to prevent this sort of direct
interaction with the hardware and software of the machine on which they're
running, for obvious reasons. E.g. if a web app can delete
C:\MyUploadFile.txt, what's to stop it also deleting C:\bootmgr? A bit of an
extreme example, but I trust you get the point...



Not natively... You'd need to look at some sort of ActiveX control for this,
but that would mean that you'd have to ramp the browser security right down
just to get it to load, never mind run...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Mark, thanks for your help, I will discuss this with my users.
Julia
 
Julia said:
Users have requested one application as, although only one pc will upload
documents, the users on that pc will also use all the other functions and
don't want to move between applications, so a web application has been
selected to be the best method for the whole thing.

With this in mind is there any way around this?

Have the server delete the file via UNC, e.g.
\\THE_PC\C$\DirectoryName\Filename
 
Back
Top