diff --git a/Oqtane.Server/Controllers/FileController.cs b/Oqtane.Server/Controllers/FileController.cs index 677d922d..4f5bcb2f 100644 --- a/Oqtane.Server/Controllers/FileController.cs +++ b/Oqtane.Server/Controllers/FileController.cs @@ -760,13 +760,23 @@ namespace Oqtane.Controllers { if (!Directory.Exists(folderpath)) { - try + string path = folderpath.StartsWith(Path.DirectorySeparatorChar) ? Path.DirectorySeparatorChar.ToString() : string.Empty; + var separators = new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }; + string[] folders = folderpath.Split(separators, StringSplitOptions.RemoveEmptyEntries); + foreach (string folder in folders) { - Directory.CreateDirectory(folderpath); - } - catch (Exception ex) - { - _logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Unable To Create Folder {Folder}", folderpath); + path = Utilities.PathCombine(path, folder, Path.DirectorySeparatorChar.ToString()); + if (!Directory.Exists(path)) + { + try + { + Directory.CreateDirectory(path); + } + catch (Exception ex) + { + _logger.Log(LogLevel.Error, this, LogFunction.Create, ex, "Unable To Create Folder {Folder}", path); + } + } } } }