2011年6月28日 星期二

抓取檔案目前的權限狀態

因為要設定檔案的權限
而且不想改變該檔其他帳號的權限
所以用了下方的方式去抓取 以及設定


        private static void SetAccessRule(
            string fileName
            , string accountName
            , FileSystemRights rights
            , AccessControlType controlType)
        {
            var account
                = new NTAccount(accountName);

            var accessRule
                = new FileSystemAccessRule(account, rights, controlType);

            var securityDescriptor
                = new FileSecurity(fileName, AccessControlSections.Access);
         
            var accessRuleCollection
                = securityDescriptor.GetAccessRules(true, true, typeof(NTAccount));
         
            securityDescriptor.SetAccessRule(accessRule);

            File.SetAccessControl(fileName, securityDescriptor);

        }

2011年6月27日 星期一

installutil.exe - Win 7下注意事項

因為win7的權限控管
所以在使用installutil 時
記得要先用 Adminstrator 的角色 開啟 Visual Studio的 command 工具列
否則會一直收到 system.security.securityexception the source was not found ... 的 Exception

2011年6月16日 星期四

Recursive queries

在PTT的CSherp板看到的問題
沒遇到這種需求
記錄一下 晚點來看看

reference:

SQL Server:
http://www.mssqltips.com/tip.asp?tip=938

Oracle:
http://rwijk.blogspot.com/2009/11/recursive-subquery-factoring.html

2011年6月9日 星期四

關於private / protect 方法是否該測試

如果該方法是很重要的
是可以用Reflection的方法去做

http://www.cnblogs.com/confach/articles/225502.html


visual studio 2010似乎有提供方法可以測試
晚點來試試看

http://msdn.microsoft.com/zh-tw/library/bb385974.aspx