Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to create a new folder with access control in asp.net 4.0 using c#, please help me.
Posted

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
 
Share this answer
 
Comments
Varun Sareen 23-Feb-12 23:04pm    
good links sakryukov..take my 4
Sergey Alexandrovich Kryukov 23-Feb-12 23:09pm    
...but not good enough, I guess? :-)
Thanks anyway...
--SA
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 23-Feb-12 23:12pm    
What, hard-coded path names? There are no situations when it can help. And under ASP.NET, first two samples won't work at all, and in desktop applications, this is illegal in Windows 7. At least you should have warned about it, if you knew about it by yourself...
--SA
Varun Sareen 23-Feb-12 23:53pm    
have updated my answer
Varun Sareen 23-Feb-12 23:42pm    
i am not aware of this...well thanks for the same :)
While ASP .NET framework already provides support for role based access control (RBAC), we can use the membership classes.

C#
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:

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900