OS independent file paths & Utility.PathCombine added

System.IO.Path.Combine provides cross-platform support for system paths, however rooted paths discarding of earlier segments
Utilities.PathCombine ensures if any parameters start with root chacters does not discard previous Utilities.PathCombine allows appending of "\\" to translate to the correct cross-platform result
This commit is contained in:
Sean Long
2020-04-18 14:57:31 -04:00
parent 194f5674b4
commit f0043f53ee
11 changed files with 37 additions and 18 deletions

View File

@ -431,12 +431,12 @@ namespace Oqtane.Controllers
private string GetFolderPath(Folder folder)
{
return Path.Combine(_environment.ContentRootPath, "Content", "Tenants", _tenants.GetTenant().TenantId.ToString(), "Sites", folder.SiteId.ToString(), folder.Path, " ").TrimEnd(' ');
return Utilities.PathCombine(_environment.ContentRootPath, "Content", "Tenants", _tenants.GetTenant().TenantId.ToString(), "Sites", folder.SiteId.ToString(), folder.Path);
}
private string GetFolderPath(string folder)
{
return Path.Combine(_environment.WebRootPath, folder, " ").TrimEnd(' ');
return Utilities.PathCombine(_environment.WebRootPath, folder);
}
private void CreateDirectory(string folderpath)
@ -448,7 +448,7 @@ namespace Oqtane.Controllers
string[] folders = folderpath.Split(separators, StringSplitOptions.RemoveEmptyEntries);
foreach (string folder in folders)
{
path = Path.Combine(path, folder);
path = Utilities.PathCombine(path, folder,"\\");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);