![](/img/trans.png)
[英]Creating a Folder in C#, Applying Permissions, But access is still DENIED?
[英]creating nested folder in c# shows access denied error
我正在尝试以嵌套方式创建文件夹。
if (file.ContentLength > 0 && file != null)
{
string path = "~/Videos/" + Session["username"] + "_" + Session["userid"];
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string filename = path + file.FileName;
filepath = "/Videos/" + Session["username"] + "_" + Session["userid"];
file.SaveAs(filename);
如果您在这里看到- /Videos/
文件夹是我当前在磁盘上的文件夹。 我要在此“ Videos
文件夹中创建带有用户名和ID的另一个文件夹。 我将如何在此文件夹中创建此文件夹?
因为当前它向我显示此错误-
Access to the path '~/Videos/shaun_2' is denied.
我尝试使用管理员的凭据重新启动Visual Studio。 但是它仍然保留在这里。
我假设您正在使用ASP.NET:请尝试使用Server.MapPath("~/...")
来获取物理路径
参见MSDN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.