Grant read-only access to a file in C#

17/06/2011

During the code cleaning I was doing last week, there was a section that granted a user read only access to a file

It was nasty code because it involved Active Directory, SIDs, Local Path of UNCs, WMI which was over 100 lines.  My cleaned up version only takes 5 lines excluding error handling.

                FileInfo fileToAlter = new FileInfo(fullPath);
                FileSecurity security = fileToAlter.GetAccessControl();
                FileSystemAccessRule rule = new FileSystemAccessRule(userID, FileSystemRights.Read, AccessControlType.Allow);
                security.AddAccessRule(rule);
                fileToAlter.SetAccessControl(security);

The error handling the code does is to throw an exception with a custom message.

I gained the knowledge from this useful MSDN Article on Managing Access to Windows Objects with ACLs in .Net.

People Upload News theme songs?

20/10/2010

Was looking around on youtube.com and I found that people have actually uploaded the opening to various news programs. I am surprised that people actually went to the trouble of making them into a video.

As example here is a video that the user linxthesontaran has compiled of passed and present Free to Air Australian News Themes. It is interesting to see how they have changed.

Bonus +100 Rep on StackExchange Sites

24/08/2010

Found out the other day you can get +100 bonus reputation on StackExchange Sites eg StackOverflow.

To get the 100 reputation bonus you need to have an account with one site where you have 200 or greater reputation.

This post on the stack overflow blog explains it better:

http://blog.stackoverflow.com/2010/05/new-automatic-account-association/

Exit Path is a Fun Flash Game

18/08/2010

Been playing the flash game Exit Path produced by armor games.

It has a single player mode which is a performer. The faster you complete all 30 levels the better your score is.(It’s Time based). The game also allows you to submit your score to see how you rank amongst other game players.  My best time is currently 6min, 8.8 seconds.

There is an multi-player mode which allows you to race through various levels.  The multi-player is especially nice because it automatically arranges opponents, you don’t have to wait in a ‘lobby‘.

Another feature of the game is that it have various achievements.  eg Complete Single playing in under 7 minutes or win 100 multi-player matches.  Achievements unlock various items you can customise your character with eg It can wear a hat and run with scissors.

I would rate it 8/10.


Follow

Get every new post delivered to your Inbox.