Explorer view losing folder path information RRS feed

  • Question

  • Hi all,

    I am writing a custom webpart to replace SP's default ListWebPart in my document library view page. But I found it can't keep the folder information when showing the "Explorer View". For example, I enter a subfolder "root/folder 1" and select "Explorer View" in  ViewToolbar, it returns the root folders content. But when I click the "Open in Windows Explorer" in ActionMenu, it returns contents of folder 1.

    I see the Sharepoint's ListViewWebpart does not have this problem. It can return correct contents when I enter a sub folder and click "Explorer View". The page's url contains correnct query strings about folder path (in my own webpart the query string is missing). Is it because I forget some config for the toolbar since I add it via codes?

    Below is my code to add the toolbar:


         SPView view = this.CurrentView;
         if (view == null) return null;
        this._toolbar = new ViewToolBar();
        this._toolbar.ID = this.ID + "_ViewToolBar";
        this._toolbar.RenderContext = SPContext.Current;
        if (!String.IsNullOrEmpty(view.ToolbarTemplateName))
         this._toolbar.TemplateName = view.ToolbarTemplateName;
        return this._toolbar;


    Thanks a lot.


    Tuesday, September 14, 2010 5:41 AM


  • Finally got the solution. Set RootFolder property using reflector.


    //must set the ViewContext.RootFolder, otherwise the Explore view will always goto the root folder.
     rootFolder = Page.Request.QueryString["RootFolder"
    (rootFolder != null
     && rootFolder != list.RootFolder.Url)
     viewCtx = context.ViewContext;
     rootFolderField = viewCtx.GetType().GetProperty("RootFolder"
    , BindingFlags.Instance|BindingFlags.NonPublic);
     rootFolderField.SetValue(viewCtx, rootFolder, null
    For anyone else has the same problem, this may help.


    • Proposed as answer by Hemendra Agrawal Thursday, September 16, 2010 3:35 AM
    • Marked as answer by KeFang Chen Monday, September 20, 2010 9:57 AM
    Thursday, September 16, 2010 1:38 AM