How to make a copy of a file as Readonly?

I export the date to an Excel spreadsheet programmatically in a Windows Forms application. When I save the Excel file, I put this file only as read. If the user creates a copy of the Excel file, he can change it, but I want to limit cloning (not to allow duplicate copies), and if there is also a copy of the file, I want to do this also read-only.

I do not want to use passwords. Can this be done?

Thank you in advance

+4
source share
3 answers

It's impossible.

Read-only is available for β€œaccidental” rewriting only; it is not a security system.

+1
source

What you want to do would be possible only if the operating system had some kind of permission that indicated "do not allow copies." However, as far as I know, no operating system (at least Windows, since I assume that this is what is used as the theme, these are C # and Excel files, but I do not exclude it) has this as a specific permission case.

In any case, if there was this option, and the data was set to read-only, someone could read the file in memory, and then output a new file with this specific data. There are more philosophical points about how to prevent copies - it's useless work ( DRM ), but I will just save some time and say that it will be difficult, if not impossible.

However, if you want, you can encrypt the file so that it cannot be used directly in Excel. Then create a kind of wrapper that reads in the encrypted file, decrypts it, and then passes it to Excel. So that someone does not copy the file and does not modify it, you would need to transfer the decrypted data directly to Excel, but I'm not sure if this is possible or not, since I do not have much experience using Excel, not to mention creating applications, who work with him.

If transferring data to Excel does not work, you can try putting the decrypted file in another directory to throw it away, but I doubt it will fool anyone with any quick wits or definition.

If the file in question is supposed to be used directly with Excel (you create Excel files so that someone opens Excel), I would say that it would be impossible to prevent them from changing the file.

0
source

If something is on the client side, and if the client can view it, you cannot stop it for copying it.

0
source

All Articles