[英]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.