Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a file present on server. The file on server is read-only. When I download the file from ASP .NET application to my local machine, the file has read and write access both. The original read-only attribute removed. I want to download the file read-only mode. Could you please suggest the proper solution for this problem

What I have tried:

I have tried couple of options like using response.transaferfile option.
Response.ContentType = "test/plain";
Response.AppendHeader("Content-Disposition", "attachment; filename=MyFile.txt");
Response.TransmitFile(Server.MapPath("~/Files/MyFile.txt"));
Response.End();


On server, this file has read-only attribute, but if I download using above code, the read-only attribute remove automatically in client location. I want to prevent file read-only after downloading. Please suggest some solution.
Posted
Updated 2-Mar-18 10:41am

You can't. The server has no control over where - or even if - the file is saved on the client, nor what attributes or permissions are applied to it.

And you don't need to anyway. If the user edits their copy of the file, it won't have any effect on the server's copy.
 
Share this answer
 
If you don't want the user to make any changes to what information is downloaded, you need to convert it to a format that you can control editing.

You can do this with PDF files, and I think you can do it with Office documents as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900