How to make a copy of file as Readonly?
I am exporting the date to an Excel spreadsheet programatically in a Windows Forms Application. When I am saving the Exce开发者_如何学Gol file, I am marking that file as read only. If the user creates a copy of Excel file,then they can modify it, but I want to restrict the cloning(Dont allow duplicate copies) and if there is a copy of file also,I want to make that also read only.
I don't want to use any passwords.
Is this possible to do?Thanks in advance
This is not possible.
Read only is only for "accidental" overwriting anyway; it's not a security system.
What you want to do would only be possible if there were some permission in an operating system that specified 'don't allow copies.' However, as far as I know, no operating system (at least Windows, as I assume that is what is being used as the topic is C# and Excel files, but I'm sure not exclusive to it) has this as a specific permission case.
Anyway, if there were this option and the data was set to 'readonly,' someone could read the file into memory and then output a new file with that specific data. There are more philosophical points on how preventing copies is a useless endeavour (DRM) but I'll just save some time and state it would be hard, if not impossible.
However, if you wanted, you could encrypt the file so that it couldn't be used directly in Excel. Then, create a sort of wrapper that reads in the encrypted file, decrypts it, then passes it along to Excel. To prevent someone from copying the file and modifying it you would have to pass the decrypted data directly to Excel but I'm not sure if that is possible or not as I don't have much experience with using Excel, let alone making applications that work together with it.
If passing in the data to Excel will not work, you could try putting the decrypted file in a different directory to throw them off, but I doubt this would trick anyone with any savvy or determination.
If the file in question is supposed to be used directly with Excel (you are generating Excel files for someone to open with Excel) then I would say that preventing them modifying the file would not be possible.
If something is there at client side, and if client can view it then you cannot stop him for making it's copy.
精彩评论