Hi i am facing a problem when open root file its not open,
Here is my code:
<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" Width="734px" Height="400px"
EnableOpenFile="true" OnExplorerPopulated="RadFileExplorer1_ExplorerPopulated"
VisibleControls="Grid,TreeView,ContextMenus,Toolbar">
<Configuration ViewPaths="~/UserData/FacilityFile/" DeletePaths="~/UserData/FacilityFile/"
UploadPaths="~/UserData/FacilityFile/" SearchPatterns="*.pdf" />
</telerik:RadFileExplorer>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomColumnsContentProvider).AssemblyQualifiedName;
RadFileExplorer1.InitialPath = Page.ResolveUrl("~/UserData/FacilityFile/" + Id.ToString() + "/");
string[] DocPaths = new string[] { RadFileExplorer1.InitialPath };
RadFileExplorer1.Configuration.ViewPaths = DocPaths;
RadFileExplorer1.Configuration.UploadPaths = DocPaths;
RadFileExplorer1.Configuration.DeletePaths = DocPaths;
}
InitializeComponent();
}
protected override void OnInit(EventArgs e)
{
RadFileExplorer1.Localization.SetString("Common_ConfirmDelete", "Are you sure you want to Delete?");
}
private void InitializeComponent()
{
DirectoryInfo nd = new DirectoryInfo(Server.MapPath("~/UserData/FacilityFile/" + Id.ToString()));
if (!nd.Exists)
{
nd.Create();
}
}
protected void RadFileExplorer1_ExplorerPopulated(object sender, RadFileExplorerPopulatedEventArgs e)
{
//implement sorting for the custom Date column
string sortingColumn = e.SortColumnName;
if (sortingColumn == "Date")
{
DateComparer dc = new DateComparer();
e.List.Sort(dc);
if (e.SortDirection.IndexOf("DESC") != -1)
{
//reverse order
e.List.Reverse();
}
}
}
public class DateComparer : IComparer<FileBrowserItem>
{
int IComparer<FileBrowserItem>.Compare(FileBrowserItem item1, FileBrowserItem item2)
{
//treat folders separate from files
DateTime date1 = DateTime.Parse(item1.Attributes["Date"]);
DateTime date2 = DateTime.Parse(item2.Attributes["Date"]);
if (item1 is DirectoryItem)
{
if (item2 is DirectoryItem)
{
return DateTime.Compare(date1, date2);
}
else
{
return -1;
}
}
else
{
if (item2 is DirectoryItem)
{
return 1;
}
else
{
return DateTime.Compare(date1, date2);
}
}
}
}
public class CustomColumnsContentProvider : FileSystemContentProvider
{
public CustomColumnsContentProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
: base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
{
// Declaring a constructor is required when creating a custom content provider class
}
}
Here is my code:
<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" Width="734px" Height="400px"
EnableOpenFile="true" OnExplorerPopulated="RadFileExplorer1_ExplorerPopulated"
VisibleControls="Grid,TreeView,ContextMenus,Toolbar">
<Configuration ViewPaths="~/UserData/FacilityFile/" DeletePaths="~/UserData/FacilityFile/"
UploadPaths="~/UserData/FacilityFile/" SearchPatterns="*.pdf" />
</telerik:RadFileExplorer>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadFileExplorer1.Configuration.ContentProviderTypeName = typeof(CustomColumnsContentProvider).AssemblyQualifiedName;
RadFileExplorer1.InitialPath = Page.ResolveUrl("~/UserData/FacilityFile/" + Id.ToString() + "/");
string[] DocPaths = new string[] { RadFileExplorer1.InitialPath };
RadFileExplorer1.Configuration.ViewPaths = DocPaths;
RadFileExplorer1.Configuration.UploadPaths = DocPaths;
RadFileExplorer1.Configuration.DeletePaths = DocPaths;
}
InitializeComponent();
}
protected override void OnInit(EventArgs e)
{
RadFileExplorer1.Localization.SetString("Common_ConfirmDelete", "Are you sure you want to Delete?");
}
private void InitializeComponent()
{
DirectoryInfo nd = new DirectoryInfo(Server.MapPath("~/UserData/FacilityFile/" + Id.ToString()));
if (!nd.Exists)
{
nd.Create();
}
}
protected void RadFileExplorer1_ExplorerPopulated(object sender, RadFileExplorerPopulatedEventArgs e)
{
//implement sorting for the custom Date column
string sortingColumn = e.SortColumnName;
if (sortingColumn == "Date")
{
DateComparer dc = new DateComparer();
e.List.Sort(dc);
if (e.SortDirection.IndexOf("DESC") != -1)
{
//reverse order
e.List.Reverse();
}
}
}
public class DateComparer : IComparer<FileBrowserItem>
{
int IComparer<FileBrowserItem>.Compare(FileBrowserItem item1, FileBrowserItem item2)
{
//treat folders separate from files
DateTime date1 = DateTime.Parse(item1.Attributes["Date"]);
DateTime date2 = DateTime.Parse(item2.Attributes["Date"]);
if (item1 is DirectoryItem)
{
if (item2 is DirectoryItem)
{
return DateTime.Compare(date1, date2);
}
else
{
return -1;
}
}
else
{
if (item2 is DirectoryItem)
{
return 1;
}
else
{
return DateTime.Compare(date1, date2);
}
}
}
}
public class CustomColumnsContentProvider : FileSystemContentProvider
{
public CustomColumnsContentProvider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)
: base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
{
// Declaring a constructor is required when creating a custom content provider class
}
}