In my website i want to create a new folder and then copy some files in it and also i want to create an html
file through C#
code. I want to know
Im using Asp.net MVC 2
and C#
.
Right-click on any file/folder, and select “Properties”. To check the permissions, head to the “Permission” tab.
Permissions of 644 mean that the owner of the file has read and write access, while the group members and other users on the system only have read access.
755 means read and execute access for everyone and also write access for the owner of the file. When you perform chmod 755 filename command you allow everyone to read and execute the file, the owner is allowed to write to the file as well.
Some file permission examples: 777 - all can read/write/execute (full access). 755 - owner can read/write/execute, group/others can read/execute. 644 - owner can read/write, group/others can read only.
How to check read and write permission on a folder
string folder = ...
var permission = new FileIOPermission(FileIOPermissionAccess.Write, folder);
var permissionSet = new PermissionSet(PermissionState.None);
permissionSet.AddPermission(permission);
if (permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet))
{
// You have write permission for the given folder
}
How to create an html file on runtime in project root
string file = Path.Combine(Server.MapPath("~/"), "foo.html");
File.WriteAllText(file, "<html><body><h1>Hello</h1></body></html>");
why don't you use App_Data where the identity of ASP.NET application automatically has read and write permissions?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With