private void CopySpriteFiles(string appSpritesPath, string path) { var files = Directory.EnumerateFiles(path); var timeStamp = File.ReadAllText(Path.Combine(path, "lowCompat.css")); var folderKey = FileGenerator.GenerateKey(timeStamp); foreach (var file in files) { var fileName = Path.GetFileName(file); var fileRelativePath = file.Substring(appSpritesPath.Length, file.Length - appSpritesPath.Length); var keyedFolderPath = Path.Combine(this.config.StorageFolderName, appStritesFolderName, folderKey); var keyedFolder = HostingEnvironment.MapPath("~/" + keyedFolderPath); if (!Directory.Exists(keyedFolder)) { Directory.CreateDirectory(keyedFolder); } var filePathStore = Path.Combine(keyedFolderPath, fileRelativePath); if (fileRelativePath.Length > fileName.Length) { // Create the subfolder if it doesn't exist var folder = HostingEnvironment.MapPath("~/" + filePathStore.Substring(0, filePathStore.Length - fileName.Length)); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } } if (fileName.StartsWith("sprite") || fileName.StartsWith("blank.gif")) { var destFile = HostingEnvironment.MapPath("~/" + filePathStore); if (File.Exists(destFile)) { File.Delete(destFile); } File.Copy(file, destFile); } if (fileName == "highCompat.css" || fileName == "lowCompat.css") { var parser = new CssGenerator(); var originalVirtualPath = "~/" + appStritesFolderName + "/" + fileRelativePath.Replace("\\", "/"); var parserResult = parser.Parse(originalVirtualPath); //var cssFilePath = filePathStore.Replace(fileName, parserResult.Key + ".css"); var fixedContent = parserResult.Content.Replace(@"\5c\2f", @"\/").Replace(@"\5c\2e", @"\."); SaveFile(filePathStore, fixedContent); spriteCssFiles.Add(originalVirtualPath, filePathStore.Replace("\\", "/").Replace(this.config.StorageFolderName + "/", string.Empty)); } } }
public void RegisterCombinedCssFiles(string name, params string[] files) { var parser = new CssGenerator(); RegisterCombinedDocument(parser, cssFiles, name, "css", files); }