OS independent file paths

This commit is contained in:
Sean Long
2020-04-17 16:25:00 -04:00
parent 2dd2216aa2
commit 70502cd881
13 changed files with 41 additions and 36 deletions

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using Oqtane.Repository;
using Microsoft.AspNetCore.Hosting;
using Oqtane.Shared;
using System.IO;
namespace Oqtane.SiteTemplates
{
@ -131,16 +132,16 @@ namespace Oqtane.SiteTemplates
}
});
if (System.IO.File.Exists(_environment.WebRootPath + "\\images\\logo.png"))
if (System.IO.File.Exists(Path.Combine(_environment.WebRootPath, "images", "logo.png")))
{
string folderpath = _environment.ContentRootPath + "\\Content\\Tenants\\" + site.TenantId.ToString() + "\\Sites\\" + site.SiteId.ToString() + "\\";
string folderpath = Path.Combine(_environment.ContentRootPath, "Content", "Tenants", site.TenantId.ToString(), "Sites", site.SiteId.ToString());
System.IO.Directory.CreateDirectory(folderpath);
if (!System.IO.File.Exists(folderpath + "logo.png"))
if (!System.IO.File.Exists(Path.Combine(folderpath, "logo.png")))
{
System.IO.File.Copy(_environment.WebRootPath + "\\images\\logo.png", folderpath + "logo.png");
System.IO.File.Copy(Path.Combine(_environment.WebRootPath, "images", "logo.png"), Path.Combine(folderpath, "logo.png"));
}
Folder folder = _folderRepository.GetFolder(site.SiteId, "");
File file = _fileRepository.AddFile(new File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
Oqtane.Models.File file = _fileRepository.AddFile(new Oqtane.Models.File { FolderId = folder.FolderId, Name = "logo.png", Extension = "png", Size = 8192, ImageHeight = 80, ImageWidth = 250 });
site.LogoFileId = file.FileId;
_siteRepository.UpdateSite(site);
}