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

Folder Browse in Telerik

5 Answers 242 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
: Arumuga Vignesh
Top achievements
Rank 1
: Arumuga Vignesh asked on 25 Jul 2013, 02:52 PM

Hi All,

I have requirement in my project to select a required folder path using folder browse window.

After selecting the path, file name is appended and the file is generated in the selected path

How to implement it in Telerik

Thanks In Advance

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 26 Jul 2013, 07:31 AM
Hi,

You can use the RadFileExplorer to achieve your requirement. Please have a look into the following code I tried which works fine at my end.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="Select Path" AutoPostBack="false"
    OnClientClicked="OpenFileExplorerDialog">
</telerik:RadButton>
<telerik:RadWindow ID="RadWindow1" runat="server" Width="400px" Height="350px">
    <ContentTemplate>
        <br />
        <telerik:RadButton ID="RadButton2" runat="server" Text="Select folder and Create File"
            Skin="Hay" ButtonType="LinkButton" OnClick="RadButton2_Click1">
        </telerik:RadButton>
        <br />
        <br />
        <telerik:RadFileExplorer ID="RadFileExplorer1" VisibleControls="Toolbar,TreeView"
            Width="365px" Height="300px" runat="server" EnableOpenFile="false">
            <Configuration ViewPaths="~/RadAsyncUpload" EnableAsyncUpload="false" AllowMultipleSelection="false" />
        </telerik:RadFileExplorer>
    </ContentTemplate>
</telerik:RadWindow>

JavaScript:
<script type="text/javascript">
    function OpenFileExplorerDialog() {
        var radwindow = $find("<%= RadWindow1.ClientID %>");
        //opening RadWindow containing the RadFileExplorer.
        radwindow.show();
    }
</script>

C#:
protected void RadButton2_Click1(object sender, EventArgs e)
{
    //getting the selected path in radfileexplorer
    string selectedpath = Server.MapPath(RadFileExplorer1.CurrentFolder);
         
    //Sample code to create file in the above path obtained.
    string filename = "MyFile.txt";
    File.Create(Path.Combine(selectedpath, filename));
}

Thanks,
Shinu.
0
: Arumuga Vignesh
Top achievements
Rank 1
answered on 26 Jul 2013, 11:06 AM
Thanks,But I am not able see the foder structures inside the file explorer window
0
Shinu
Top achievements
Rank 1
answered on 29 Jul 2013, 04:38 AM
Hi Arumuga,

You are unable to see the folder structure because the VisibleControls property is set to Toolbar, TreeView. You can remove this property and then all the controls will be visible by default and hence the user can view the folder structure including all the files. Please check the following mark-up.

ASPX:
<telerik:RadFileExplorer ID="RadFileExplorer1" Width="100%" Height="200px" runat="server" EnableOpenFile="false">
    <Configuration ViewPaths="~/Images" EnableAsyncUpload="false" AllowMultipleSelection="false" />
</telerik:RadFileExplorer>

Thanks,
Shinu.
0
: Arumuga Vignesh
Top achievements
Rank 1
answered on 29 Jul 2013, 11:25 AM

Thanks,

Now I am able to see the folders

But I am only accessible to the current working folder. How to get the all folders in the file browser window (Eg My Computer,C:,D:,Desktop, My Documents like options)

0
Shinu
Top achievements
Rank 1
answered on 30 Jul 2013, 04:34 AM
Hi Arumuga,

The default content provider of the file explorer control only works with files and folders from the current web application. You cannot access files on another computer or on a different drive.

What you can do in this case is open the IIS configuration and create a virtual folder in your web application, which points to the files on the remote drive. Make sure that the appropriate ASP.NET windows user has permissions to at least read the files on the remote folder. Otherwise you might see "access is denied" errors when you try to browse with the file explorer control.

Another possible option to list physical paths' content in RadFileExplorer is to implement a custom content provider, ensuring that all permissions to the pointed folders are set correctly. Please have a look at this KB article on Use RadFileExplorer with physical and shared folder's paths which demonstrates the sample implementation of such a provider.

Thanks,
Shinu.
Tags
General Discussions
Asked by
: Arumuga Vignesh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
: Arumuga Vignesh
Top achievements
Rank 1
Share this question
or