Unplanned
Last Updated: 13 Jan 2020 12:09 by ADMIN
Nguyen Huu
Created on: 07 Jan 2020 09:11
Category: UI for ASP.NET AJAX
Type: Feature Request
0
how to know Owner after new folder(s) or upload file(s) by RadFileExplorer?
how to know Owner after new folder(s) or upload file(s) by RadFileExplorer?
2 comments
ADMIN
Rumen
Posted on: 13 Jan 2020 12:09

Hello,

I am afraid that RadFileExplorer does not provide the desired functionality out of the box and you will need to implement in on your own. The reason for that is the system remembers the name of the current owner of the uploaded file (usually the server administrator).

Optionally you can consider using a custom DataBase content provider, where to store and update the desired author information in it.

You can add a custom attribute to the file Items in RadFileExplorer (both the already listed and the uploaded ones) by applying the approach shown in the Custom columns demo of the control:
https://demos.telerik.com/aspnet-ajax/fileexplorer/examples/applicationscenarios/customgridcolumns/defaultcs.aspx

The following article explains the implemented in the demo logic in details:
https://docs.telerik.com/devtools/aspnet-ajax/controls/fileexplorer/how-to/adding-custom-grid-columns

For example:

public new override DirectoryItem ResolveDirectory(string path)
{
    // Update all file items with the additional information (date, owner)
    DirectoryItem oldItem = base.ResolveDirectory(path);
    foreach (FileItem fileItem in oldItem.Files)
    {
        // Get the information from the physical file
        FileInfo fInfo = new FileInfo(Context.Server.MapPath(VirtualPathUtility.AppendTrailingSlash(oldItem.Path) + fileItem.Name));

        string ownerName = "Telerik"; // your logic for setting the owner of the file here
        fileItem.Attributes.Add("Owner", ownerName);
    }
    return oldItem;
}

 

Public Overloads Overrides Function ResolveDirectory(ByVal path As String) As DirectoryItem
    ' Update all file items with the additional information (date, owner)
    Dim oldItem As DirectoryItem = MyBase.ResolveDirectory(path)
    For Each fileItem As FileItem In oldItem.Files
        ' Get the information from the physical file
        Dim fInfo As New FileInfo(Context.Server.MapPath(VirtualPathUtility.AppendTrailingSlash(oldItem.Path) + fileItem.Name))
 
        Dim ownerName As String = "Telerik" 'your logic for setting the owner of the file here
        fileItem.Attributes.Add("Owner", ownerName)
    Next
    Return oldItem
End Function

Regards,
Rumen
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Nguyen Huu
Posted on: 08 Jan 2020 04:12

Hi all,

 

how to know Owner after I have been put an extends class FileSystemContentProvider and override DirectoryItem ResolveDirectory & override DirectoryItem ResolveRootDirectoryAsTree

public override DirectoryItem ResolveDirectory(string path)
        {
            DirectoryItem oldItem = base.ResolveDirectory(path);

            foreach (FileItem fileItem in oldItem.Files)
            {
                FileInfo fInfo = new FileInfo(string.Format("{0}{1}", GetServerMapPath(oldItem.Path), fileItem.Name));

                fileItem.Attributes.Add("CreationTimeFileInfo", fInfo.CreationTime.ToString());
                fileItem.Attributes.Add("LastWriteTimeFileInfo", fInfo.LastWriteTime.ToString());
                fileItem.Attributes.Add("LastAccessTimeFileInfo", fInfo.LastAccessTime.ToString());                
            }

            return oldItem;
        }

 

public override DirectoryItem ResolveRootDirectoryAsTree(string path)
        {
            DirectoryItem oldItem = base.ResolveRootDirectoryAsTree(path);

            foreach (DirectoryItem dirItem in oldItem.Directories)
            {
                DirectoryInfo dInfo = new DirectoryInfo(GetServerMapPath(dirItem.Path));

                dirItem.Attributes.Add("CreationTimeFileInfo", dInfo.CreationTime.ToString());
                dirItem.Attributes.Add("LastWriteTimeFileInfo", dInfo.LastWriteTime.ToString());
                dirItem.Attributes.Add("LastAccessTimeFileInfo", dInfo.LastAccessTime.ToString());                
            }
            return oldItem;
        }

Please helps me! Thanks all!