Is there a way to get File Information During Upload using rad FileManger

2 posts, 0 answers
  1. Corey
    Corey avatar
    9 posts
    Member since:
    Mar 2012

    Posted 02 Mar 2012 Link to this post

    I need to get the info of the file while it is uploading to insert the record into the database. Such as the size of the file. Is there anyway to do that? In the Upload File case.
    protected void rfeStorage_ItemCommand(object sender, RadFileExplorerEventArgs e)
           {
               //file manager
               string path = e.Path.Remove(0, e.Path.IndexOf("/") + 1);
               path = path.Remove(0, path.IndexOf("/") + 1);
               path = path.Replace("/", @"\");
               path = @oCompany.StorageBoxLocation + @"\" + path;
               using (UNCAccessWithCredentials unc = Generic.GetDocumentCredentials(path.Remove(path.LastIndexOf(@"\"))))
               {
                   if (unc.NetUseWithCredentials())
                   {
                       switch (e.Command)
                       {
                           case "UploadFile":
                               FilesCOL f = new FilesCOL();
                               f.Name = Path.GetFileName(path);
                               f.UserID = oUsers.UserID;
                               f.isShared = false;
                               f.isDeleted = false;
                               FilesDAL.Insert(ref f);
     
                               FileLogCOL fileLog = new FileLogCOL();
                               fileLog.UserID = oUsers.UserID;
                               fileLog.Action = "Uploaded";
                               fileLog.LogDate = DateTime.Now;
                               fileLog.FilePath = path;
                               fileLog.FileID = f.FileID;
                               FileLogDAL.Insert(ref fileLog);
                               break;
     
                           case "MoveDirectory":
                               break;
     
                           case "CreateDirectory":
                               break;
     
                           case "DeleteDirectory":
                               break;
     
                           case "DeleteFile":
     
     
     
                               FileLogCOL fileLog3 = new FileLogCOL();
                               FileLogCOL fileLog5 = FileLogDAL.SelectFileLog(path);
                               fileLog3.UserID = oUsers.UserID;
                               fileLog3.Action = "Deleted";
                               fileLog3.LogDate = DateTime.Now;
                               fileLog3.FilePath = getNewPath(e.Path);
                               fileLog3.FileID = fileLog5.FileID;
                               FileLogDAL.Insert(ref fileLog3);
                               FilesCOL f2 = FilesDAL.Select(fileLog3.FileID);
                               f2.isDeleted = true;
                               FilesDAL.Update(ref f2);
                               break;
     
                           case "MoveFile":
     
     
                               FileLogCOL fileLog2 = new FileLogCOL();
                               FileLogCOL fileLog4 = FileLogDAL.SelectFileLog(path);
     
                               fileLog2.FilePath = getNewPath(e.NewPath);
                               fileLog2.UserID = oUsers.UserID;
                               fileLog2.Action = "Moved";
                               fileLog2.LogDate = DateTime.Now;
                               fileLog2.FileID = fileLog4.FileID;
                               FileLogDAL.Insert(ref fileLog2);
                               break;
                       }
                   }
               }
           }

  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 07 Mar 2012 Link to this post

    Hi Corey,

    To achieve the required functionality I would suggest you to sub-class the RadFileExplorer's default content provider and override the StoreFile() and DeleteFile() methods to execute the database modifications as well.

    More information regarding the RadFileExplorer's content provider is available in the following help article:
    Using custom FileBrowserContentProvider

    All the best,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top