Click here to Skip to main content
13,147,689 members (32,235 online)
Rate this:
Please Sign up or sign in to 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.

Posted 19-Sep-12 6:52am
Wes Aday 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.
@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.
As Wes already advised, you can have the file in a resource embedded in an executable module. You can use .resx. How about that?
@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:
Sergey Alexandrovich Kryukov 20-Sep-12 11:32am
The performance is the same as in case of reading the file (when the resource is accessed for the first time), but you can additionally cash the data.
@AmitGajjar 21-Sep-12 0:49am
Ohh ok...Thank you SA.
Actually, performance cost for video should not be considerable. When you read the video stream each time from the file, the video is successfully shown, after all. And it can be shown if read from much slower network stream. So, you should not worry about it. The problem could be just the opposite: it could be fast enough but take too much memory if you try to load it all from the resource. Them you should open resource stream and play as you read...
@AmitGajjar 21-Sep-12 1:00am
You are correct. but sometimes user do not have much budget to spend on the project. And upto 100MBs of files i should not worry as it will work on desktop applications. Anyway lets see some streaming server that can stream local video so in future that can be helpful. :)
Sergey Alexandrovich Kryukov 21-Sep-12 11:36am
For a streaming server, I usually recommend VideoLAN (VLC). There is a .NET wrapper as well.
@AmitGajjar 24-Sep-12 0:30am
Ok, thanks for the information.
ahmedfaruk88 28-Sep-12 10:35am
Good, i appreciate your comment on this, the project budget does not cover creating a windows service, i think i will go with the resource file trick. Thanks

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

When your application is running you can lock it as :
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.
@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
My 5. I disagree with the vote of 1, of course. (But stay calm; it happens all the time...)
Kuthuparakkal 20-Sep-12 1:51am
Thank you SA.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100