新聞中心
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í)例演示:
- /*C#創(chuàng)建文件夾并設(shè)置權(quán)限*//*
- 需要添加以下命名空間:
- using System.IO;
- using System.Security.AccessControl;
- */
- string sPath = Server.MapPath(文件夾名稱字符串);
- Directory.CreateDirectory(sPath);
- addpathPower(sPath, "ASPNET", "FullControl");
- /*///////C#創(chuàng)建文件夾并設(shè)置權(quán)限////////////////*/
- public void addpathPower(
- string pathname, string username, string power)
- {
- DirectoryInfo dirinfo = new DirectoryInfo(pathname);
- if ((dirinfo.Attributes & FileAttributes.ReadOnly) != 0)
- {
- dirinfo.Attributes = FileAttributes.Normal;
- }
- //C#創(chuàng)建文件夾取得訪問控制列表
- DirectorySecurity dirsecurity = dirinfo.GetAccessControl();
- switch (power)
- {
- case "FullControl":
- dirsecurity.AddAccessRule(new FileSystemAccessRule(
- username, FileSystemRights.FullControl,
- InheritanceFlags.ContainerInherit,
- PropagationFlags.InheritOnly, AccessControlType.Allow));
- break;
- case "ReadOnly":
- dirsecurity.AddAccessRule(
- new FileSystemAccessRule(username,
- FileSystemRights.Read, AccessControlType.Allow));
- break;
- case "Write":
- dirsecurity.AddAccessRule(
- new FileSystemAccessRule(username,
- FileSystemRights.Write, AccessControlType.Allow));
C#創(chuàng)建文件夾的一些具體實(shí)現(xiàn)的操作就先你介紹到這里,希望對你了解和學(xué)習(xí)C#創(chuàng)建文件夾的過程以及實(shí)現(xiàn)相關(guān)的權(quán)限設(shè)置有所幫助。
本文名稱:淺析C#創(chuàng)建文件夾實(shí)現(xiàn)實(shí)例
轉(zhuǎn)載來于:http://fisionsoft.com.cn/article/dhsgcdi.html


咨詢
建站咨詢
