Physical Paths

12 posts, 0 answers
  1. OnionMan
    OnionMan avatar
    2 posts
    Member since:
    Jan 2007

    Posted 18 May 2009 Link to this post

    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  
    ---------------------------

  2. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 19 May 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Doug
    Doug avatar
    7 posts
    Member since:
    Feb 2009

    Posted 01 Jun 2009 Link to this post

    Is there a fix to this issue yet, I too would like to use this for folders located outside of the web structure.
  5. OnionMan
    OnionMan avatar
    2 posts
    Member since:
    Jan 2007

    Posted 01 Jun 2009 Link to this post

    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.
  6. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 02 Jun 2009 Link to this post

    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.
  7. Vivek
    Vivek avatar
    3 posts
    Member since:
    Apr 2008

    Posted 04 Jun 2009 Link to this post

    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
  8. Jeremy
    Jeremy avatar
    1 posts
    Member since:
    Jun 2009

    Posted 09 Jun 2009 Link to this post

    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
  9. rami
    rami avatar
    3 posts
    Member since:
    Sep 2012

    Posted 03 Jul 2009 Link to this post

    Guys! find fix yet??
    thanks
  10. Wim van der Linden
    Wim van der Linden avatar
    37 posts
    Member since:
    Nov 2008

    Posted 22 Jul 2009 Link to this post

    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:

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

    The content provider class:

    1 using System;  
    2 using System.Collections.Generic;  
    3 using System.Linq;  
    4 using System.Web;  
    5 using System.IO;  
    6 using Telerik.Web.UI.Widgets;  
    7  
    8     public class NewWorkFileBrowserContentProvider : Telerik.Web.UI.Widgets.FileBrowserContentProvider  
    9     {  
    10  
    11         //constructor must be present when overriding a base content provider class  
    12         //you can leave it empty  
    13         public NewWorkFileBrowserContentProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)  
    14             : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)  
    15         {  
    16         }  
    17  
    18         public override Telerik.Web.UI.Widgets.DirectoryItem ResolveRootDirectoryAsTree(string path)  
    19         {  
    20              
    21             DirectoryInfo root = new DirectoryInfo(path);  
    22  
    23             FileInfo[] files = root.GetFiles();  
    24             FileItem[] items = GetFilesItemsByFileInfo(files);  
    25  
    26             DirectoryItem rootitem = new DirectoryItem(root.Name, root.FullName, root.FullName, root.Name, PathPermissions.Read, items, GetChildFolderItems(root.GetDirectories()));  
    27            
    28             return rootitem;  
    29         }  
    30         public override Telerik.Web.UI.Widgets.DirectoryItem ResolveDirectory(string path)  
    31         {  
    32             DirectoryInfo root = new DirectoryInfo(path);  
    33             FileInfo[] files = root.GetFiles();  
    34             FileItem[] items = GetFilesItemsByFileInfo(files);  
    35             DirectoryItem rootitem = new DirectoryItem(root.Name, root.FullName, root.FullName, root.Name, PathPermissions.Read, items, GetChildFolderItems(root.GetDirectories()));  
    36  
    37             return rootitem;  
    38         }  
    39           
    40          /// <summary>  
    41         /// <para>Loops through the child folders of the root.</para>  
    42         /// </summary>  
    43         /// <param name="info"></param>  
    44         /// <returns></returns>  
    45         private DirectoryItem[] GetChildFolderItems(DirectoryInfo[] info)  
    46         {  
    47             List<DirectoryItem> fullList = new List<DirectoryItem>();  
    48  
    49             foreach (DirectoryInfo inf in info)  
    50             {  
    51                 FileInfo[] files = inf.GetFiles();  
    52                 FileItem[] items = GetFilesItemsByFileInfo(files);  
    53                 DirectoryItem newItem = new DirectoryItem(inf.Name, inf.FullName, inf.FullName, "", PathPermissions.Read, items, GetChildFolderItems(inf.GetDirectories()));  
    54                 fullList.Add(newItem);  
    55             }  
    56  
    57             return fullList.ToArray();  
    58         }  
    59  
    60  
    61         /// <summary>  
    62         /// <para>Converts the fileinfo array to a telerik FileItem array</para>  
    63         /// </summary>  
    64         /// <param name="files"></param>  
    65         /// <returns></returns>  
    66         private FileItem[] GetFilesItemsByFileInfo(FileInfo[] files)  
    67         {  
    68             List<FileItem> items = new  List<FileItem>();  
    69  
    70             foreach (FileInfo info in files)  
    71             {  
    72                 //For images thumbs.db gets created by windows  
    73                 //I do not want to view those files.  
    74                 if (info.Name.ToLower().Contains("thumbs.db")) continue;  
    75  
    76                 FileItem item = new FileItem(info.Name, info.Extension, info.Length, info.FullName, """", PathPermissions.Read);  
    77                 items.Add(item);  
    78  
    79             }  
    80  
    81             return items.ToArray();  
    82         }  
    83  
    84         public override string GetFileName(string url)  
    85         {  
    86             return "";  
    87         }  
    88         public override string GetPath(string url)  
    89         {  
    90             return "";  
    91         }  
    92         public override System.IO.Stream GetFile(string url)  
    93         {  
    94             System.IO.StreamReader reader = new StreamReader(url);  
    95               
    96             return reader.BaseStream;  
    97         }  
    98         public override string StoreBitmap(System.Drawing.Bitmap bitmap, string url, System.Drawing.Imaging.ImageFormat format)  
    99         {  
    100             return "";  
    101         }  
    102         public override string StoreFile(Telerik.Web.UI.UploadedFile file, string path, string name, params string[] arguments)  
    103         {  
    104             return "";  
    105         }  
    106         public override string DeleteFile(string path)  
    107         {  
    108             return "";  
    109         }  
    110         public override string DeleteDirectory(string path)  
    111         {  
    112             return "";  
    113         }  
    114         public override string CreateDirectory(string path, string name)  
    115         {  
    116             return "";  
    117         }  
    118         public override string MoveFile(string path, string newPath)  
    119         {  
    120             return base.MoveFile(path, newPath);  
    121         }  
    122         public override string MoveDirectory(string path, string newPath)  
    123         {  
    124             return base.MoveDirectory(path, newPath);  
    125         }  
    126     }   
    127  
    128  

    hope this helps you guys a bit further.

    kind regards,
    Wim
  11. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 24 Jul 2009 Link to this post

    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.
  12. hp
    hp avatar
    2 posts
    Member since:
    Apr 2014

    Posted 04 Apr 2014 in reply to Fiko Link to this post

    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.
  13. Vessy
    Admin
    Vessy avatar
    1380 posts

    Posted 09 Apr 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017