从我的 aspx 页面我试图创建一个文件。但如果尝试从根文件夹创建文件,则会引发此错误消息( System.UnauthorizedAccessException: Access to the path '~/Image/User/mrrrrrfcom' is denied. )
Image1.ImageUrl = "~/Image/User/noneUserImage.jpg";
String folderPath = Path.Combine("~/Image/User/mrrrrrfcom", "mrrrrrfcom");
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
但是如果我给它这样的路径它会起作用
String folderPath = Path.Combine("G:/AA/BB/CC/DD/Image/User/", "mrrrrrfcom");
但是您需要从根访问权限创建文件,以便该项目适用于其他计算机。