Skip to main content
All docs
V24.2

'The X has no access to path Y' or 'Access to the path X is denied' for File and Image Controls

Error Description

The errors occur when you use the following controls:

Solution

Use the following API to specify permissions for file (IO) operations:

Control Property
ASPxImageSlider ASPxImageSlider.SettingsAutoGeneratedImages.ImageCacheFolder
ASPxImageGallery ASPxImageGallery.SettingsFolder.ImageCacheFolder
ASPxUploadControl ASPxUploadControl.AdvancedModeSettings.TemporaryFolder
ASPxSpreadsheet ASPxSpreadsheet.SettingsDocumentSelector.EditingSettings.TemporaryFolder,
ASPxSpreadsheet.WorkDirectory
ASPxRichEdit ASPxRichEdit.WorkDirectory

You can use the code below in the Page_Init event handler to check if the specified Web Server’s directory has permissions for file operations:

using System.IO;  
...  

protected void Page_Init(object sender, EventArgs e) {  
    string dirVirtualPath = "~/TestDir";  
    string dirPhysicalPath = MapPath(dirVirtualPath);  
    if(!Directory.Exists(dirPhysicalPath)) {  
        Directory.CreateDirectory(dirPhysicalPath);  
    }  

    string fileName = "TestFile.txt";  
    string fileFullPath = Path.Combine(dirPhysicalPath, fileName);  

    File.WriteAllText(fileFullPath, "File Content Here...");  

}