日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
淺析C#創(chuàng)建文件夾實(shí)現(xiàn)實(shí)例

C#創(chuàng)建文件夾如何實(shí)現(xiàn),以及C#創(chuàng)建文件夾之后的設(shè)置權(quán)限的操作,是我們經(jīng)常會碰到的實(shí)際問題,那么如何實(shí)現(xiàn)C#創(chuàng)建文件夾以及C#創(chuàng)建文件夾之后的設(shè)置權(quán)限的操作是什么呢?讓我們看看實(shí)際的操作代碼:

在金溪等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站制作、成都做網(wǎng)站 網(wǎng)站設(shè)計制作按需網(wǎng)站建設(shè),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計,成都營銷網(wǎng)站建設(shè),成都外貿(mào)網(wǎng)站建設(shè)公司,金溪網(wǎng)站建設(shè)費(fèi)用合理。

C#創(chuàng)建文件夾實(shí)例演示:

 
 
 
  1. /*C#創(chuàng)建文件夾并設(shè)置權(quán)限*//*  
  2. 需要添加以下命名空間:  
  3. using System.IO;  
  4. using System.Security.AccessControl;  
  5. */  
  6.   
  7. string sPath = Server.MapPath(文件夾名稱字符串);   
  8. Directory.CreateDirectory(sPath);   
  9. addpathPower(sPath, "ASPNET", "FullControl");   
  10.   
  11. /*///////C#創(chuàng)建文件夾并設(shè)置權(quán)限////////////////*/   
  12.   
  13. public void addpathPower(
  14. string pathname, string username, string power)   
  15. {   
  16.   
  17. DirectoryInfo dirinfo = new DirectoryInfo(pathname);   
  18.   
  19. if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)   
  20. {   
  21. dirinfo.Attributes = FileAttributes.Normal;   
  22. }   
  23.   
  24. //C#創(chuàng)建文件夾取得訪問控制列表   
  25. DirectorySecurity dirsecurity = dirinfo.GetAccessControl();   
  26.   
  27. switch (power)   
  28. {   
  29. case "FullControl":   
  30. dirsecurity.AddAccessRule(new FileSystemAccessRule(
  31. username, FileSystemRights.FullControl, 
  32. InheritanceFlags.ContainerInherit, 
  33. PropagationFlags.InheritOnly, AccessControlType.Allow));   
  34. break;   
  35. case "ReadOnly":   
  36.    dirsecurity.AddAccessRule(
  37. new FileSystemAccessRule(username, 
  38. FileSystemRights.Read, AccessControlType.Allow));   
  39. break;   
  40. case "Write":   
  41. dirsecurity.AddAccessRule(
  42. new FileSystemAccessRule(username, 
  43. FileSystemRights.Write, AccessControlType.Allow));   

C#創(chuàng)建文件夾的一些具體實(shí)現(xiàn)的操作就先你介紹到這里,希望對你了解和學(xué)習(xí)C#創(chuàng)建文件夾的過程以及實(shí)現(xiàn)相關(guān)的權(quán)限設(shè)置有所幫助。


文章標(biāo)題:淺析C#創(chuàng)建文件夾實(shí)現(xiàn)實(shí)例
分享網(wǎng)址:http://www.dlmjj.cn/article/dhsgcdi.html