public int ChangeLogo([FromBody] LogoChangeInfo changeInfo) { int result = 0; try { changeInfo.ImagePath = changeInfo.ImagePath.TrimStart('/'); string destinationFolder = Path.Combine(_hostingEnvironment.WebRootPath, logoFolderPath, changeInfo.FolderName); string srcImagePath = Path.Combine(_hostingEnvironment.WebRootPath, changeInfo.ImagePath); string extension = Path.GetExtension(srcImagePath); //delete existing image first if (new DirectoryInfo(destinationFolder).Exists) { DirectoryInfo di = new DirectoryInfo(destinationFolder); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } string FileName = "Contentder"; System.IO.File.Copy(srcImagePath, Path.Combine(destinationFolder, FileName + extension), true); result = 1; } } catch { result = 0; } return(result); }
public int ChangeFavicon([FromBody] LogoChangeInfo changeInfo) { int result; try { string destinationPath = Path.Combine(_hostingEnvironment.WebRootPath, "favicon.ico"); string sourcePath = Path.Combine(_hostingEnvironment.WebRootPath, changeInfo.ImagePath); System.IO.File.Copy(sourcePath, destinationPath, true); result = 1; } catch { result = 0; } return(result); }