This is a migrated thread and some comments may be shown as answers.
Auto-create Missing Folder
2 Answers 19 Views
This is a migrated thread and some comments may be shown as answers.
Chris Miller
Top achievements
Rank 1
Chris Miller asked on 01 Apr 2010, 03:18 AM
Our FileExplorer looks for a folder called /uploaded-files/. Is there a way to auto-create this folder if it doesn't exist?

2 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 05 Apr 2010, 02:40 PM
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.
0
Chris Miller
Top achievements
Rank 1
answered on 05 Apr 2010, 04:40 PM
Excellent, thank you.
Asked by
Chris Miller
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Chris Miller
Top achievements
Rank 1
Share this question
or