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

Physical Paths

11 Answers 416 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
OnionMan
Top achievements
Rank 2
OnionMan asked on 18 May 2009, 10:26 PM

Has anyone managed to create a FileBrowserContentProvider to handle physical paths outside the web app? I have a scenario where I need files to be managed outside of the application, and it appears that everything wants virtual paths!

Looking at the demo I also thought of using a httphandler for the files, however that isn’t working. I got as far as getting the directory tree to show in the left tree view however no files are being shown.

I am by no means an ASP.net expert and am still learning the ropes, so if anyone can point me in the right direction I'd be most grateful.

I Keep getting errors like below thrown up:

---------------------------
Message from webpage
---------------------------
Callback Loading error:
D:\Test\
Unrecognized escape sequence. (14): { path : "D:\Test\", sortExpression : ""}96|/wEWCAL4tITjBwL8w9uGDALztZepDwLytZepDwL1tZepDwL0tZepDwLvtZepDwLutZepD4v1sVL6WoAl9jmHj5iuS6WymetQ
---------------------------
OK  
---------------------------

11 Answers, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 19 May 2009, 10:47 AM
Hello,

Which version of the RadControls are you using? Try getting the latest internal build from http://www.telerik.com/account/latest-internal-builds.aspx. It seems the problem is that the path we submit to the server is not properly escaped (the \ path separator needs to be escaped).

Kind regards,
Lini
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Doug
Top achievements
Rank 1
answered on 01 Jun 2009, 07:45 PM
Is there a fix to this issue yet, I too would like to use this for folders located outside of the web structure.
0
OnionMan
Top achievements
Rank 2
answered on 01 Jun 2009, 09:46 PM
Hi,

I managed to get it working, still need to polish it up and work out some kinks. I am using a handler to provide the files, and as Lini said you need to escape the back slashes for the paths. Once its working correctly I will put it in the code gallery.
0
Tervel
Telerik team
answered on 02 Jun 2009, 07:53 AM
Hi OnionMan,

We are looking forward to your code library contribution! (as are the forum users reading this thread :)

Best regards,
Tervel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Vivek
Top achievements
Rank 1
answered on 04 Jun 2009, 09:09 AM
Hi Onionman,

We too are facing this issue. Currently FileBrowser is working only in case of files within the Web Application. But for our application, files will be in a shared folder like \\server\images and this does not work with the FileBrowser. Any updates on this is really appreciated. Thanks!

Regards,
Vivek
0
Jeremy
Top achievements
Rank 1
answered on 09 Jun 2009, 09:30 PM
Hi Onionman,

I too have this issue, and would like to know how to use a shared folder (like \\server\folder) with the RadFileExplorer.

Regards,
Jeremy
0
rami
Top achievements
Rank 1
answered on 03 Jul 2009, 01:40 PM
Guys! find fix yet??
thanks
0
Wim van der Linden
Top achievements
Rank 1
answered on 22 Jul 2009, 02:20 PM
Hey guys,

I needed the fileviewer to view content from a network location,see the code below for a custom content provider solution to do so.

the code below shows the content provider that reads all the files and folders of the given path.

like I said its just for viewing so I didnt implement anything else (yet).
It's a start, take a look at it, it works for the network paths like vivek requested. I did not test it on physical paths but I expect it to work in the same way.

There is one but to this solution. If the network folder is protected by a domain user login, this will crash
when the GetFiles() method is called. In other words it won't work then.
Haven't found a solution for that (yet).

A other thing I noticed is that when using the Q2 2009 release open file might throw a JSON error.
Untill I know why I'm using the Q1 2009 where it works perfectly.

For a telerik employee I get the following message:
"Microsoft JScript runtime error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON.
Parameter name: data".

the call:

FileExplorer1.Configuration.ContentProviderTypeName = typeof(NewWorkFileBrowserContentProvider).AssemblyQualifiedName;  
         

The content provider class:

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.IO;  
using Telerik.Web.UI.Widgets;  
 
    public class NewWorkFileBrowserContentProvider : Telerik.Web.UI.Widgets.FileBrowserContentProvider  
    {  
 
        //constructor must be present when overriding a base content provider class  
        //you can leave it empty  
        public NewWorkFileBrowserContentProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)  
            : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)  
        {  
        }  
 
        public override Telerik.Web.UI.Widgets.DirectoryItem ResolveRootDirectoryAsTree(string path)  
        {  
             
            DirectoryInfo root = new DirectoryInfo(path);  
 
            FileInfo[] files = root.GetFiles();  
            FileItem[] items = GetFilesItemsByFileInfo(files);  
 
            DirectoryItem rootitem = new DirectoryItem(root.Name, root.FullName, root.FullName, root.Name, PathPermissions.Read, items, GetChildFolderItems(root.GetDirectories()));  
           
            return rootitem;  
        }  
        public override Telerik.Web.UI.Widgets.DirectoryItem ResolveDirectory(string path)  
        {  
            DirectoryInfo root = new DirectoryInfo(path);  
            FileInfo[] files = root.GetFiles();  
            FileItem[] items = GetFilesItemsByFileInfo(files);  
            DirectoryItem rootitem = new DirectoryItem(root.Name, root.FullName, root.FullName, root.Name, PathPermissions.Read, items, GetChildFolderItems(root.GetDirectories()));  
 
            return rootitem;  
        }  
          
         /// <summary>  
        /// <para>Loops through the child folders of the root.</para>  
        /// </summary>  
        /// <param name="info"></param>  
        /// <returns></returns>  
        private DirectoryItem[] GetChildFolderItems(DirectoryInfo[] info)  
        {  
            List<DirectoryItem> fullList = new List<DirectoryItem>();  
 
            foreach (DirectoryInfo inf in info)  
            {  
                FileInfo[] files = inf.GetFiles();  
                FileItem[] items = GetFilesItemsByFileInfo(files);  
                DirectoryItem newItem = new DirectoryItem(inf.Name, inf.FullName, inf.FullName, "", PathPermissions.Read, items, GetChildFolderItems(inf.GetDirectories()));  
                fullList.Add(newItem);  
            }  
 
            return fullList.ToArray();  
        }  
 
 
        /// <summary>  
        /// <para>Converts the fileinfo array to a telerik FileItem array</para>  
        /// </summary>  
        /// <param name="files"></param>  
        /// <returns></returns>  
        private FileItem[] GetFilesItemsByFileInfo(FileInfo[] files)  
        {  
            List<FileItem> items = new  List<FileItem>();  
 
            foreach (FileInfo info in files)  
            {  
                //For images thumbs.db gets created by windows  
                //I do not want to view those files.  
                if (info.Name.ToLower().Contains("thumbs.db")) continue;  
 
                FileItem item = new FileItem(info.Name, info.Extension, info.Length, info.FullName, """", PathPermissions.Read);  
                items.Add(item);  
 
            }  
 
            return items.ToArray();  
        }  
 
        public override string GetFileName(string url)  
        {  
            return "";  
        }  
        public override string GetPath(string url)  
        {  
            return "";  
        }  
        public override System.IO.Stream GetFile(string url)  
        {  
            System.IO.StreamReader reader = new StreamReader(url);  
              
            return reader.BaseStream;  
        }  
        public override string StoreBitmap(System.Drawing.Bitmap bitmap, string url, System.Drawing.Imaging.ImageFormat format)  
        {  
            return "";  
        }  
        public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)  
        {  
            return "";  
        }  
        public override string DeleteFile(string path)  
        {  
            return "";  
        }  
        public override string DeleteDirectory(string path)  
        {  
            return "";  
        }  
        public override string CreateDirectory(string path, string name)  
        {  
            return "";  
        }  
        public override string MoveFile(string path, string newPath)  
        {  
            return base.MoveFile(path, newPath);  
        }  
        public override string MoveDirectory(string path, string newPath)  
        {  
            return base.MoveDirectory(path, newPath);  
        }  
    }   
 
 

hope this helps you guys a bit further.

kind regards,
Wim
0
Fiko
Telerik team
answered on 24 Jul 2009, 03:23 PM
Hello,

I believe that this Code Library will be of help.

All the best,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
hp
Top achievements
Rank 1
answered on 04 Apr 2014, 03:17 PM
Hi Fiko

I implemented the customfilebrowser using online resources available. I have network path outside the application and called using webservice to create/delete folder/file.

If I select a folder/subfolder, i get Cannot deserialize. The data does not correspond to valid JSON., and grid doesn't refresh.
0
Vessy
Telerik team
answered on 09 Apr 2014, 11:27 AM
Hello,

This error might occur if some of the results of some of RadFileExplorer's AJAX calls is corrupted. Are you, by any chance, tracking the response output at the page or application level (e.g. the response time of a page)?

To be able to provide more to the point answer we will need to examine and debug the issue. Could you, please, try to isolate the issue into a simple fully runnable project and send it for a further investigation?

Also, could you please provide a fiddler log captured the problematic scenario? You can find information how to work with this useful tool here: http://www.west-wind.com/weblog/posts/596348.aspx.

Looking forward to hearing from you,

Vessy
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
FileExplorer
Asked by
OnionMan
Top achievements
Rank 2
Answers by
Lini
Telerik team
Doug
Top achievements
Rank 1
OnionMan
Top achievements
Rank 2
Tervel
Telerik team
Vivek
Top achievements
Rank 1
Jeremy
Top achievements
Rank 1
rami
Top achievements
Rank 1
Wim van der Linden
Top achievements
Rank 1
Fiko
Telerik team
hp
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or