Click here to Skip to main content
15,915,611 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good day guys, its quite a long time. Please help me with this little headache.
I am developing a WinForm C# application which is use to launch a .chm file, like i mean when a button is clicked a .chm file is launched, for now the operation is smooth, but after creating an installer file for the app, I'll like to implement a kinda security which will prevent the .chm file on the target system from been launched or copied.

Please does any one know how to go about this.

Thanks
Posted
Comments
[no name] 19-Sep-12 12:58pm    
I think that this is a bad idea. Probably way more trouble than it's worth. But you could embed your help file as a resource, extract it before viewing and then delete the copy when you are done. Or change the extension and hide the file.
Sergey Alexandrovich Kryukov 19-Sep-12 15:20pm    
Absolutely bad idea; I totally agree. I would not bother to answer. I prefer helping to wasting time to the useless features.
--SA
AmitGajjar 20-Sep-12 1:07am    
Hi SA, Actually i had some requirement year before where i need to store some videos but that videos should not be viewed without the application. But then the project droped by the client. So it would be nice if you can give your thought on this. i think OP also have similar requirement to protect chm file to be shared without the application.
Sergey Alexandrovich Kryukov 20-Sep-12 1:40am    
As Wes already advised, you can have the file in a resource embedded in an executable module. You can use .resx. How about that?
--SA
AmitGajjar 20-Sep-12 2:05am    
I have question about performance when using resource file, but some discussion says that it is working fine even with GBs of Data. So :ThumbsUp:

1 solution

When your application is running you can lock it as :
C#
using (FileStream fs =
         File.Open("MyFilepath", FileMode.Open, FileAccess.Read, FileShare.None))
{
   // use fs
}


If you would like to have a permanent lock even when your application is not running :

You may think of Windows Service with the above code.
 
Share this answer
 
Comments
AmitGajjar 20-Sep-12 1:02am    
What if anyone stop the service ?
Kuthuparakkal 20-Sep-12 1:08am    
You can create unstoppable service buddy. Service has a property "CanStop", set it to false...
AmitGajjar 20-Sep-12 2:08am    
Ohh is it so? i don't know. 5+ for this comment :)

I am eager to read about CanStop, how it will work when exception occur. and all other stuff. Thanks for sharing your knowledge.

Kuthuparakkal 20-Sep-12 1:30am    
balls you dare drop comments on downvote
Sergey Alexandrovich Kryukov 20-Sep-12 1:42am    
My 5. I disagree with the vote of 1, of course. (But stay calm; it happens all the time...)
--SA

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