private UploadProcessingResult HandleZipFile() { try { var RelativePath = _database + @"\" + LocalFileName.Replace(".zip", "").Split('\\').Last(); // NOTE: BaseDirectory ends with a \ but we don't include the \ in the .Replace method. var DirectoryName = AppDomain.CurrentDomain.BaseDirectory.ToLower().Replace("GHuploader", @"GHweb\eps\training\customsites") + RelativePath; var indexFound = false; using (ZipArchive archive = ZipFile.OpenRead(LocalFileName)) { if (archive.Entries.Any(file => file.Name.ToLower() == "presentation_html5.html")) { ZipFile.ExtractToDirectory(LocalFileName, DirectoryName); indexFound = true; } } if (indexFound) { File.Delete(LocalFileName); var result = new UploadProcessingResult() { IsComplete = true, FileName = OriginalFileName.Replace(".zip", ""), LocalFilePath = RelativePath + @"\presentation_html5.html", FileMetadata = _streamProvider.FormData }; result.FileMetadata.Add("isCustomSite", "true"); return(result); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw ex; } return(null); }
private void StripExtensionAndCleanFileName() { FileNameExtension = OriginalFileName.Substring(OriginalFileName.LastIndexOf('.')); _fileNameWithoutExtensionAndClean = Regex.Replace(OriginalFileName.Replace(FileNameExtension, String.Empty), @"[\._-]+", " "); }