Auto-create Missing Folder

3 posts, 0 answers
  1. Chris Miller
    Chris Miller avatar
    13 posts
    Member since:
    Jun 2006

    Posted 31 Mar 2010 Link to this post

    Our FileExplorer looks for a folder called /uploaded-files/. Is there a way to auto-create this folder if it doesn't exist?
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 05 Apr 2010 Link to this post

    Hello Nik,

      In your scenario I recommend you to use this approach:

    • Set the path(s) dynamically in the Page_Load event
    • Check whether the path(s) that will be set to the RadFileExplorer's VIewPaths property already exists:
      Directory.Exists(Server.MapPath(virtualPath))
    • If the path does not exist then create it :
      Directory.CreateDirectory(Server.MapPath(virtualPath))
    The code should look like similar to this:
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim viewPaths As String() = New String() {"~/ROOT"}
        If Not System.IO.Directory.Exists(Server.MapPath(viewPaths(0))) Then
            System.IO.Directory.CreateDirectory(Server.MapPath(viewPaths(0)))
        End If
     
        ' "~/ROOT" already exists
        RadFileExplorer1.Configuration.ViewPaths = viewPaths
    End Sub

    I hope this helps.

    Best wishes,
    Fiko
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Chris Miller
    Chris Miller avatar
    13 posts
    Member since:
    Jun 2006

    Posted 05 Apr 2010 Link to this post

    Excellent, thank you.
Back to Top