如何创建一个新文件夹 [英] how to create a new folder

查看:120
本文介绍了如何创建一个新文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#在asp.net 4.0中创建具有访问控制的新文件夹,请帮助我.

How to create a new folder with access control in asp.net 4.0 using c#, please help me.

推荐答案

您可以使用System.IO.Directory.CreateDirectory http://msdn.microsoft.com/en-us/library/system.io.directory. aspx [^ ].

您可能遇到的一个问题是找出要传递的正确路径名,以获取目录名参数.请阅读以下内容:
http://msdn.microsoft.com/en-us/library/ms178116.aspx [ ^ ].

—SA
You can use System.IO.Directory.CreateDirectory, http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^].

One problem you might have is finding out right path name to be passes for a directory name parameter. Please read this:
http://msdn.microsoft.com/en-us/library/ms178116.aspx[^].

—SA


尝试:-

http://msdn.microsoft.com/en-us/library/system.io. directory.aspx [^ ]

http://www.dotnetperls.com/directory-createdirectory [ http://en.csharp-online.net/Create_a_directory [ http://www.dotnetspider.com/resources/7625-Directory- Create-Check-Delete-Using-C.aspx [ ^ ]

不要忘记使用
try this :-

http://msdn.microsoft.com/en-us/library/system.io.directory.aspx[^]

http://www.dotnetperls.com/directory-createdirectory[^]

http://en.csharp-online.net/Create_a_directory[^]

http://www.dotnetspider.com/resources/7625-Directory-Create-Check-Delete-Using-C.aspx[^]

dont forget to add using
System.IO;

命名空间添加.

如果可以帮助您,请别忘了将此标记为您的答案.

谢谢

name space.

Don''t forget to mark this as your answer if it helps you out.

Thanks


虽然ASP .NET框架已经提供了对基于角色的访问控制(RBAC)的支持,但是我们可以使用成员资格类.

While ASP .NET framework already provides support for role based access control (RBAC), we can use the membership classes.

public class User {
  public string Name { get; set; }
  public int Role { get; set; }
  public bool IsInRole(Role role) {
     Role userRole = (Role)this.Role;
     return ((userRole & role) == role);
  }
}
[Flags]
public enum Role {
   Associate = 1,
   Manager = 2
}



用户界面代码为:



User Interface code as:

<div class="LeftMenu"> 
  <% if (user.IsInRole(Role.Manager)) %>
    <% thisDir = Server.MapPath(".");
       System.IO.Directory.CreateDirectory(thisDir + "\\NewFolder1"); %>
</div>


这篇关于如何创建一个新文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆