For any SharePoint document library there is a default view called "Explorer View". This view displays the the contents of the document library as Windows explorer window that can be used to drag/drop or copy/paste files. This is very handy when transferring large sets of files/folders to a SharePoint document library.
Recently I implemented this view in a custom aspx page. Here's how I did it:
- Add the explorer view container to your page. The explorer view uses an iframe as the container for the windows explorer window. Here is what the markup should look like.
<iframe id="frmFolder" name="frmFolder" width="600" height="400" src="/_layouts/blank.htm" class="ms-httpFolder"> </iframe>
- Initialized the explorer view container. Add the following code to your OnLoad page handler to initialize the iframe. In this example I am loading the root folder of the site collection. You can load any SharePoint folder you like.
string js = string.Format(@" function navtoframe() {{ NavigateHttpFolderIfSupported('{0}{1}', 'frmFolder'); }} _spBodyOnLoadFunctionNames.push('navtoframe');" , SPContext.Current.Site.Url , SPContext.Current.Site.RootWeb.RootFolder.ServerRelativeUrl); Page.ClientScript.RegisterStartupScript(GetType(), "frmFolder", js, true);
The NavigateHttpFolderIfSupported method is defined in the core.js file, which is a part of the SharePoint infrastructure and is associated with all SharePoint pages.