public void InitUploadFileName(string rootLocalPath, string uploadPath) { if (string.IsNullOrEmpty(uploadPath)) { UploadFileName = LocalFileName.Replace(rootLocalPath, string.Empty); } else if (!string.IsNullOrEmpty(rootLocalPath)) { UploadFileName = string.Format("{0}/{1}", uploadPath, LocalFileName.Replace(rootLocalPath, string.Empty)); } else { UploadFileName = uploadPath; } UploadFileName = UploadFileName.Replace("//", "/"); Log.l(string.Format("UploadFileName {0}", UploadFileName)); }
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); }