'The X has no access to path Y' or 'Access to the path X is denied' for File and Image Extensions
Error Description:
The errors occur when you use the following extensions:
- ImageSliderExtension
- ImageGalleryExtension
- UploadControlExtension
- SpreadsheetExtension
- RichEditExtension
Solution:
Make sure that you granted access to the folders specified in the following properties:
- ImageSliderExtension: ImageSliderSettings.SettingsAutoGeneratedImages.ImageCacheFolder;
- ImageGalleryExtension: ImageGallerySettings.ImageCacheFolder;
- UploadControlExtension in Advanced or Auto upload mode: UploadControlExtension.AdvancedModeSettings.TemporaryFolder;
- SpreadsheetExtension: SpreadsheetSettings.SettingsDocumentSelector.EditingSettings.TemporaryFolder and SpreadsheetSettings.WorkDirectory;
- RichEditExtension: RichEditSettings.WorkDirectory.
You can use the code below in the controller action to check if the specified Web Server’s directory has permissions for file operations:
public ActionResult Index() {
string dirVirtualPath = "~/TestDir";
string dirPhysicalPath = Server.MapPath(dirVirtualPath);
if(!Directory.Exists(dirPhysicalPath)) {
Directory.CreateDirectory(dirPhysicalPath);
}
string fileName = "TestFile.txt";
string fileFullPath = Path.Combine(dirPhysicalPath, fileName);
System.IO.File.WriteAllText(fileFullPath, "File Content Here...");
return View();
}