Create TargetPhysicalFolder if it doesn't exist

3 posts, 0 answers
  1. Hakki
    Hakki avatar
    47 posts
    Member since:
    Sep 2012

    Posted 28 Apr 2015 Link to this post

    Hello,

    Title pretty much says it all but to elaborate a little, if I specify a TargetPhysicalFolder, and it has the study name (which changes per case) in it for example "D:\UploadedFiles\[studyname]", uploader errors, saying the [studyname] folder does not exist. This means I have to manually create those folders every time a new study occurs.

    It would be nice if there is an event handler I can catch and create that folder before it gives that error.

    Thanks.

  2. Milena
    Admin
    Milena avatar
    204 posts

    Posted 29 Apr 2015 Link to this post

    Hi Hakki,

    To achieve this you can override  the virtual method GetTargetFolder() which RadUploadHandler class provides and check/create the directory: 
    public class SampleUploadHandler : RadUploadHandler
       {
           public override string GetTargetFolder()
           {
               var folder = base.GetTargetFolder();
     
     
               var folderExists = Directory.Exists(folder);
               if (!folderExists)
               {
                   Directory.CreateDirectory(folder);
               }
     
               return folder;
           }
       }

    I hope this helps.

    Regards,
    Milena
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. DevCraft banner
  4. Hakki
    Hakki avatar
    47 posts
    Member since:
    Sep 2012

    Posted 29 Apr 2015 in reply to Milena Link to this post

    Perfect, thank you Milena.
Back to Top