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

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

1 Answer 50 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Corey
Top achievements
Rank 1
Corey asked on 02 Mar 2012, 04:57 PM
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;
                   }
               }
           }
       }

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 07 Mar 2012, 02:59 PM
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.
Tags
FileExplorer
Asked by
Corey
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or