Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / FileExplorer / Connecting the RadFileExplorer to a FTP filesystem

Connecting the RadFileExplorer to a FTP filesystem

Article Info

Rating: 4

Article information

Article relates to

 RadFileExplorer Q3 2009 SP1

Created by

 Fiko

Last modified

 September 08, 2010

Last modified by

 Fiko



HOW TO
Connect the RadFileExplorer control (used in the RadEditor's dialogs as well) to an FTP file system.

THE FIRST STEP
First we need to determine the format of the paths that can be set to the ViewPaths, DeletePaths and the UploadPaths properties of the RadFileExplorer control. In the current implementation, the path format looks like this:

                        Real FTP path:
 ftp://localhost/FtpSource/
 Path set to RadFileExplorer:
 /FtpSource/

The protocol and the server name, and other configurations (like user name and password) are exposed in an configuration file named FtpSettings.config. That file should be referred by using configSource property of the <appSettings> tag inside the Web.config file:
<appSettings configSource="FtpSettings.config"/>

Setting the configuration properties in that external file avoids restarting the application. If the configurations are put directly inside the Web.config file, then all changes will cause resetting the application.

FORCE THE BROWSER TO DOWNLOAD THE FILES
You can modify the Generic Handler (.ashx file) to force the browser to download the files. More information on the subject can be found in the first link at the end of this article.

HOW TO USE THE  FTP PROVIDER
The used library for FTP connection does not provide "copy" feature. The implemented in the provider "copy" logic requires a Temp directory to be created, where a file will be cached and immediately deleted. This is necessary, because when the FileCopy operation is performed, the file is downloaded from the FTP server and then immediately uploaded to the new location in the Ftp server. In the currently implemented provider you need to set the TempDirectoryPath configuration element to a valid virtual directory.

This is an example configuration file:
<?xml version="1.0"?>
<appSettings>
  <!--The name of the FTP server. Should not contain the full path to a folder - just the server's address-->
  <add key="FtpServerName"
       value="ftp://localhost"/>
  <!--User name for login. If the username is not required for connecting to the server, then leave it empty but do not remove it-->
  <add key="UserName"
       value=""/>
  <!--Password for login. If the password is not required for connecting to the server, then leave it empty but do not remove it-->
  <add key="Password"
       value=""/>
  <!--The path to a virtual folder which will contain the buffered file (when copying a file). This is necessary, because when the FileCopy method is
    performed, the file is downloaded from the FTP server and then immediately uploaded to the new location in the Ftp server-->
  <add key="TempDirectoryPath"
       value="~/Temp"/>
  <!--Path to the ASHX handler which will serve the files to the browser-->
  <add key="ItemHandlerPath"
       value="~/FtpFileSystemHandler_Cs.ashx"/>
</appSettings>


USEFUL LINKS

NOTE
In the earlier versions of the control the CheckDeletePermissions and CheckReadPermissions methods do not exist and need to be removed.

Comments

If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.