wcClient.DownloadFile (access denied)

Drstein99

Junior Contributor
Joined
Sep 26, 2003
Messages
283
Location
Audubon, Nj
I want to make an application which downloads files right to a location on "c:\test\pushFilesHere\" directory.

When I command:

Dim wcClient As System.Net.WebClient
wcClient = New System.Net.WebClient
wcClient.DownloadFile(sURL, "C:\tEST\PUSHFILESHERE\$TEMP.TXT")

---

it returns "FILE ACCESS DENIED".

How can I copy files directly to a client p/c, and avoid this ?
 
I dont know anything about user permission issues, can you please elaborate and / or provide links or documents for me to get simple started in this? I am NEW to asp.net, but a very verced database programmer.
 
I really dont have any links but I'm sure you can find stuff on google..

I was doing some CrystalReport and .net and asked someone and was told about permissions...

The thread is somewhere here and someone had a very good explanation..
 
Add the "ASPNET" user (in Microsoft Windows 2000/XP) to the ACL of the file or directory, granting permissions as need be (read/write/modify/delete). In Microsoft Windows Server 2003 you'll need to add permissions using the identity under which the application pool is running for the ASP.NET application in question.
 
I learned some things about granting permissions:

Dim fileIOPerm1 As System.Security.Permissions.FileIOPermission
fileIOPerm1.AllLocalFiles = System.Security.Permissions.FileIOPermissionAccess.AllAccess

------------

Now i can save a test bitmap:

dim b as bitmap = nothing

b = New Bitmap(100, 100)
b.Save(filename)

-------------
but when i do the download command:

wcClient.DownloadFile("http://localhost\upload3\myfilename.txt", "C:\examples\test\$test.txt")

it will report:

"URI formats are not supported."
 
Of coarse it is, the web client is configure to download to there as you asked it to. I think I know what you are trying to do, and it won't work. You can't force a file onto an anonomous user's machine. The web client, which is in this case is running on the server, is pulling a file from a remote server, which in this case happens to be local server and saving it to place specified (which the web client see's as your C drive). The web client runs on the server in this case, not the user's machine which is what I think you think is happening by reading this post.
 
I got those instructions from another thread on another web site.

LOL, maybe I'm missing something in web-client. in any case, I still dont know how to push files to my client pc yet.
 
Drstein99 said:
I got those instructions from another thread on another web site.

LOL, maybe I'm missing something in web-client. in any case, I still dont know how to push files to my client pc yet.
ASP.NET won't push files onto a client. You could have the file available for download for you client, but it will be the same as any internet web site, you'll be prompted for a 'save location'. To make a push/pull application you would need to do a traditional program, now this program could talk to a server where it pulls files from, sends config info too, etc... SMS from Microsoft and its competitors are examples of this.
 
As I read this, please allow me to understand:

THERE IS NO way to do this through asp.net automatically. I must write a custom application that users must download and install - which communicates to the server to push and pull my files?
 
I dont have time to think about security implications. I'm new to asp.net, and am not a network security administration. I'm a database programmer trying to provide live updates for software online, and re/applications of bitmaps and .jpg's and other misc files to a client pc.

So if there is a little flag I must set, or a "yes/no" promot, or a certificate I need to make, whatever the case may be. I want my clients to do this ONCE when they login, and then throughout the operation of the program, I want to send and recieve my files.
 
As Plaus said, there's just no way to easily do it because of the security considerations. You could use ActiveX or Java, but that's not really ASP and your looking at a lot of extra work. Plus ActiveX will soon go bye-bye because of all of it's exploitation - or at least be severely incapacitated...and once that happens hackers will exploit Java more and it will probably follow suit - but I digress; even with those two technologies you will have security issues is what I'm getting too. Now if they have accepted and 'trust' your product, then you won't have to worry too much; but ActiveX isn't easy and neither is Java so you're looking at a lot more development time and it may not do everything you want it to. You could of coarse create a client program that talks to your server, but it doesn't look like that is the route you want to go.

PS. Security implementations should always be your first consideration. Always make time for it. :)
 
I do not know enough about security nor do I have the taskforce on this job. I know enough about programming and computers to realize hacks and violations are inevitable, pending time and determination.

I'm looking at activeX controls now. I want to avoid a client application, for reasons too long to explain, but I will do whatever it takes in the end to accomplish the task.

Whatever technology is available for me to use here and now I will. The future of this application pends on its success today.
 
Web servers are not designed to push software out to clients, you will either need a client side utility to perform the update by polling the webserver and downloading updates or use an alternate technology.
 
Back
Top