0
我想在一個文本框txtFilenFolderName
inputed新名稱重命名文件夾:的路徑錯誤,訪問被拒絕時,重命名目錄
protected void btnUpdate_Click(object sender, EventArgs e)
{
string[] values = EditValue;
string oldpath = values[0];// = "D:\\C#Projects\\website\\Lecturer\\giangvien\\New folder"
string oldName = values[2]; //= New Folder
string newName = txtFilenFolderName.Text; //= New Folder1
string newPath = string.Empty;
if (oldName != newName)
{
newPath = oldpath.Replace(oldName, newName);
Directory.Move(oldpath, newPath);
}
else
lblmessage2.Text = "New name must not be the same as the old ";
}
}
嘗試調試:
oldpath = "D:\\C#Projects\\website\\Lecturer\\giangvien\\New folder"
oldName = New Folder
newName= New Folder1
newpath = "D:\\C#Projects\\website\\Lecturer\\giangvien\\New folder1"
一切似乎是對的,但我當我點擊按鈕編輯--->重命名--->更新--->出現錯誤:Access to the path is denied D:\\C#Projects\\website\\Lecturer\\giangvien\\New folder
幫助!