public void Save(WebResourceBase entity) { var localpath = CreateLocalPath(entity); using (FileStream fileStream = new FileStream(localpath, FileMode.Create, FileAccess.Write)) fileStream.Write(entity.Data, 0, entity.Data.Length); }
private string CreateLocalPath(WebResourceBase entity) { Regex fileNameCorrectingRegEx = new Regex("[/\\:?*\"<>|]+"); var filename = ""; var webEntity = entity as WebPage; if (webEntity != null) { filename = CreateLocalFileNameForWebpage(webEntity); } else { filename = CreateLocalFileNameForResource(entity.Url); } return(DestinationPath + fileNameCorrectingRegEx.Replace(filename, "_")); }