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

Problem with folder names with # and &

4 Answers 80 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Loy Chan
Top achievements
Rank 1
Loy Chan asked on 15 Dec 2010, 05:56 AM
I'm using a Custom File Content Provider (copied from the knowledge base).

Everything works fine except the following situations:

1. Folder name contains # or & (i.e. "Store #123")
2. User double clicks file within this folder to view the file
3. Within the FileSystemHandler.ashx file, the ProcessRequest function is called but the path of the file gets cut off at the # or & symbol

So when the code gets to the WriteFile call, it fails since it can't find the file.

Suggestions?

Loy

4 Answers, 1 is accepted

Sort by
0
Mihir Pathak
Top achievements
Rank 1
answered on 15 Dec 2010, 05:12 PM
try to encode the path. In JavaScript you can use the encodeURI() function
0
Loy Chan
Top achievements
Rank 1
answered on 15 Dec 2010, 05:21 PM
Hi,

Could you please provide a little bit more info? The FileExplorer is a bit of a black box for me.

When the user tries to open the file, I can catch this client side event with OnClientFileOpen event but where can I encode the path that eventually gets sent to the FileSystemHandler.ashx ProcessRequest method?
0
Mihir Pathak
Top achievements
Rank 1
answered on 15 Dec 2010, 05:36 PM
here is link
http://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/filteranddownloadfiles/defaultcs.aspx

 // Tell browser to open file directly
  var requestImage = encodeURI("Handler.ashx?path=" + item.get_url());

0
Loy Chan
Top achievements
Rank 1
answered on 16 Dec 2010, 05:17 AM
Hi Mihir,

Thanks for all your help. I was able to get it running with your direction.

Here's what I had to use:

        function ClientFileOpen(oExplorer, args)
        {
           var item = args.get_item();
           
           if (!item.isDirectory())
           {
               args.set_cancel(true); //this prevents the window from opening    
               var docLoc = encodeURIComponent(item.get_path());
               document.location = "FileSystemHandler.ashx?path=" + docLoc;
           }
        }

Tags
FileExplorer
Asked by
Loy Chan
Top achievements
Rank 1
Answers by
Mihir Pathak
Top achievements
Rank 1
Loy Chan
Top achievements
Rank 1
Share this question
or