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

File Explorer Dynamic path Issue in IIS

3 Answers 151 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Anto (DLL Version : 2008.3.1314.35) asked on 28 Nov 2011, 05:42 PM
Hi Everybody,

I have downloaded the latest version(2011.2.915.35) trial of telerik.

I have an file explorer control in my page in which i need to show folders in user basis,
some folders are common to all users and some are specific to users.

for example :

Users : USER-A, USER-B,

Common folders : ComFolder1,ComFolder2,ComFolder3.

User Specific folders:
FolderUser1--> for  USER-A alone
FolderUser2--> for USER-B alone

But all the folders (ComFolder1,ComFolder2,ComFolder3,FolderUser1,FolderUser2) resides in a common root folder called Fileexploredocs/documents.

My requirement is

When USER-A logs in i should show(ComFolder1,ComFolder2,ComFolder3,FolderUser1)
When USER-B logs in i should show(ComFolder1,ComFolder2,ComFolder3,FolderUser2)

For this i used the following class and function:

public partial class _Default : System.Web.UI.Page<br>{<br>protected void
Page_Load(object sender, EventArgs
e)<br>{<br>RadFileExplorer1.Configuration.ContentProviderTypeName =
typeof(CustomProvider).AssemblyQualifiedName;<br>}<br><br>public class
CustomProvider : FileSystemContentProvider<br>{<br>public
CustomProvider(HttpContext context, string[] searchPatterns, string[] viewPaths,
string[] uploadPaths, string[] deletePaths, string selectedUrl, string
selectedItemTag)<br>: base(context, searchPatterns, viewPaths, uploadPaths,
deletePaths, selectedUrl, selectedItemTag)<br>{ }<br><br>public override
DirectoryItem ResolveDirectory(string path)<br>{<br>DirectoryItem originalFolder
= base.ResolveDirectory(path);<br>FileItem[] originalFiles =
originalFolder.Files;<br>List<FileItem> filteredFiles = new
List<FileItem>();<br><br>// Filter the files<br>foreach (FileItem
originalFile in originalFiles)<br>{<br>if
(!this.IsFiltered(originalFile.Name))<br>{<br>filteredFiles.Add(originalFile);<br>}<br>}<br><br>DirectoryItem
newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location,
originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions,
filteredFiles.ToArray(), originalFolder.Directories);<br><br>return
newFolder;<br>}<br><br>public override DirectoryItem
ResolveRootDirectoryAsTree(string path)<br>{<br>DirectoryItem originalFolder =
base.ResolveRootDirectoryAsTree(path);<br>DirectoryItem[] originalDirectories =
originalFolder.Directories;<br>List<DirectoryItem> filteredDirectories =
new List<DirectoryItem>();<br><br>// Filter the folders<br>foreach
(DirectoryItem originalDir in originalDirectories)<br>{<br>if
(!this.IsFiltered(originalDir.Name))<br>{<br>filteredDirectories.Add(originalDir);<br>}<br>}<br>DirectoryItem
newFolder = new DirectoryItem(originalFolder.Name, originalFolder.Location,
originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions,
originalFolder.Files, filteredDirectories.ToArray());<br><br>return
newFolder;<br>}<br><br>private bool IsFiltered(string name)<br>{<br>if
(name.ToLower().EndsWith(".sys") ||
name.ToLower().Contains("_sys"))<br>{<br>return true;<br>}<br><br>//
else<br>return false;<br>}<br>}<br>}<br>

It worked fine for me when i run it in my local machine, i thought of testing it in a server and deployed it in a windows webserver with II7, 
its not working.

I tried debugging the application in visual studio in the same server, its working fine when i run it locally in the server, it is not working when i host it in IIS.

Anyone please give me some suggestions.

Thank You,

3 Answers, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 29 Nov 2011, 10:58 AM
Hi Anto,

I am not quite sure why this is not working on your side. I have tested the provided sample code on IIS7 and it was working as expected. Nevertheless, the filtering applied in the code is according to the file / folder name. In order to apply folder filtering according to the logged user you will have to modify the IsFiltered() method to fulfill the requirements.

However, for the described folder structure I would recommend you instead of overriding the methods of the content provider, to simply set the folders that the user can access to the ViewPaths/UploadPaths/DeletePaths properties, e.g.:
protected void Page_Load(object sender, EventArgs e)
{
    List<string> paths = new List<string>() { "~/Fileexploredocs/documents/CommonFolder1", "~/Fileexploredocs/documents/CommonFolder2", "~/Fileexploredocs/documents/CommonFolder3" };
 
    if (User1)
        paths.Add("~/Fileexploredocs/documents/User1Folder");
    if (User2)
        paths.Add("~/Fileexploredocs/documents/User2Folder");
 
    RadFileExplorer1.Configuration.ViewPaths = paths.ToArray();
    RadFileExplorer1.Configuration.DeletePaths = paths.ToArray();
    RadFileExplorer1.Configuration.UploadPaths = paths.ToArray();
}


All the best,
Dobromir
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 29 Nov 2011, 02:52 PM
Hi Dobromir,

Thank you for the reply.

Will try your solution and will update you.

I fixed it in another way,  i resolved it in another way,

I checked the path i am referring, its getting different when i run the application in local and when i run it in IIS the path is different,
i used the path that is checked while running in IIS.

I checked the following function to sort out the issue,

private bool IsFiltered(string name)
{
    if
(name.ToLower().EndsWith(".sys") ||
name.ToLower().Contains("_sys"))
    {
        checked the FullPath varible at this place in both local version and IIS version,
        it helped me
        return true;
    }
    else
        return false;
}

Your method seems to be very simple and efficient, definitely going to try that now and will update you.

Thank You,
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 05 Dec 2011, 03:25 PM
Hi Everybody,

    Is there an option to set folder delete permissions,
    consider the above sample case,
    I don't want to allow delete of the default folders and other folders can be deleted.

    Anyone please give me a suggestion.

Thank You
Tags
FileExplorer
Asked by
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Answers by
Dobromir
Telerik team
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Share this question
or