This is a migrated thread and some comments may be shown as answers.

Delete File Error

2 Answers 101 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
gianemilio redaelli
Top achievements
Rank 1
gianemilio redaelli asked on 20 Jan 2011, 04:45 PM
Hi everybody,

I configured my fe control to work on a virtual directory (IIS 6.0 on a WinSRV 2003).
WindowsAuthentication set to True, Impersonation set to True.

I can upload files, create folder, DELETE folder, but I receive a js alert when I try to delete or rename a file. The message say: "The selected file could not be deleted because the application did not have enough permissions. Please contact the administrator."
I give the impersonated user full controls to the folder but nothing ...

private void initFileManager()
{
    var sBPResourcePath = getBPResourcesPath();
    var arBPResourcePaths = new string[] { sBPResourcePath };
 
    rfeFileExplorer.AllowPaging = false;
    rfeFileExplorer.Configuration.DeletePaths = arBPResourcePaths;
    rfeFileExplorer.Configuration.UploadPaths = arBPResourcePaths;
    rfeFileExplorer.Configuration.ViewPaths = arBPResourcePaths;
    rfeFileExplorer.DisplayUpFolderItem = true;
    rfeFileExplorer.EnableCreateNewFolder = true;
    rfeFileExplorer.EnableOpenFile = true;
    //rfeFileExplorer.InitialPath = sBPResourcePath;
    rfeFileExplorer.Language = _sessionInfo.CurrentCultureCode;
    rfeFileExplorer.VisibleControls = GetVisibleControls();
}
 
private FileExplorerControls GetVisibleControls()
{
    FileExplorerControls explorerControls = 0;
 
    // explorerControls |= Telerik.Web.UI.FileExplorer.FileExplorerControls.AddressBox;
 
    explorerControls |= FileExplorerControls.Grid;
 
    explorerControls |= FileExplorerControls.Toolbar;
 
    explorerControls |= FileExplorerControls.TreeView;
 
    explorerControls |= FileExplorerControls.ContextMenus;
 
    return explorerControls;
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Dobromir
Telerik team
answered on 25 Jan 2011, 12:13 PM
Hi Gianemilio,

I already answered your support ticket on the subject. For convenience I will paste my answer here as well.

The problem that you experience is a permission issue with the permissions of the files on the IIS serve. Please note that, however, I do not know the configuration of your server and cannot provide you with a definitely working solution.

You can use the the following approach to test the permission on the server:
  • Remove the RadFileExplorer (or all RadControls) from the page
  • In the code behind of the same page where the RadFileExplorer was declared add this code:
    protected void Page_Load(object sender, EventArgs e)
    {
        string testPhysicalPath = "Path";// Physical path to an existing directory
        FillPermissionsTest(testPhysicalPath);
    }
      
    private void FillPermissionsTest(string testPhysicalPath)
    {
        try
        {
            string physicalPathToTestFolder = System.IO.Path.Combine(testPhysicalPath, "TestDirectory");
            System.IO.DirectoryInfo testDir = System.IO.Directory.CreateDirectory(physicalPathToTestFolder);// Create folder
            testDir.GetDirectories();// List folders
            string testFilePath = System.IO.Path.Combine(testDir.FullName, "TestFile1.txt");// test file paths
            System.IO.File.Create(testFilePath);// Create a file
            testDir.GetFiles("*.*");// List files
            System.IO.File.OpenRead(testFilePath).Close();// Open a file
            System.IO.File.Delete(testFilePath);// delete the test file
            System.IO.Directory.Delete(physicalPathToTestFolder);// delete the test folder
        }
        catch (Exception ex)
        {// Show the probelm
      
            string message = ex.Message;
            string script = string.Format("alert('{0}');", message);
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "KEY", script, true);
        }
    }
  • The "Paths" string should be replaced with the paths that are set to the ViewPaths, UploadPaths and DeletePaths properties of the RadFileExplorer. You can use Server.MapPath in order to retrieve the in order to get the physical paths (for example: Server.MapPath("~/App_Data/ExampleVirtualPath")), because these methods accept physical path, not virtual.
  • You need to add a break point to the beginning of the Page_Load event and make sure that the code is executed without any exceptions.
  • If an exception is thrown, then you will be sure that the problem is in the Server's permissions set to the folder(s) and not in the RadControls.
  • The highlighted ex.Message property's value will be shown as an alert if an exception occurs.

Could you please perform this test and let me know the result? In case, however, that an exception is thrown, then I recommend you to change the permissions of the folders based on the information provided in the error message.

All the best,
Dobromir
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
gianemilio redaelli
Top achievements
Rank 1
answered on 25 Jan 2011, 03:29 PM
Oooooopppsssss .... forget about that!!!

There was MY ERROR in building the paths in the getBPResourcesPath() method!

private string getBPResourcesPath()
{
    if (!sResourcesBasePath.EndsWith(@"\"))
    {
        sResourcesBasePath += @"\"; 
    }
    return sResourcesBasePath + SERVICE_BPCODE;
}

I have to use "/" instead of "\" ... the strange thing is that the folder tree is build correctly.

Sorry for boring you.

GE
Tags
FileExplorer
Asked by
gianemilio redaelli
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
gianemilio redaelli
Top achievements
Rank 1
Share this question
or