public Stream Retrieve(string filePath, EFileContainer fileContainer) { var fileLocation = _fileResolver.Resolve(_destinationPath + fileContainer + "/" + filePath); var fileStream = new FileStream(fileLocation, FileMode.Open, FileAccess.Read, FileShare.Read); return(fileStream); }
public static string MultimediaPath(string fileName, EFileContainer fileContainer) { if (fileName.IsNotNullOrEmpty()) { return(string.Format("{0}{1}{2}/{3}", ServerDomainResolver.GetCurrentDomain(), FileSettings.ContentFolder, fileContainer, fileName)); } return(string.Empty); }
public string Save(IFile file, EFileContainer fileContainer, string identifier) { var fullFileName = string.Format("{0}_{1}.{2}", identifier, fileContainer, file.Extension); var physicalPath = string.Concat(_fileResolver.Resolve(_destinationPath + fileContainer + "/"), fullFileName); using (var fileStream = System.IO.File.Create(physicalPath)) { file.Stream.Seek(0, SeekOrigin.Begin); file.Stream.CopyTo(fileStream); } return(fullFileName); }
/// <summary> /// Elimina un archivo dentro del zip /// </summary> /// <param name="EntryName">Nombre Identificador dentro del zip</param> public void DeleteFile(int identifier, EFileContainer fileContainer, string entryName) { var fullFileName = string.Format("{0}_{1}.zip", identifier, fileContainer); var physicalPath = string.Concat(_fileResolver.Resolve(_destinationPath + fileContainer + "/"), fullFileName); using (FileStream zipToOpen = new FileStream(physicalPath, FileMode.Open)) { using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update)) { ZipArchiveEntry readmeEntry = archive.GetEntry(entryName); if (readmeEntry != null) { readmeEntry.Delete(); } } } }
/// <summary> /// Agrega un archivo al zip /// </summary> /// <param name="identifier">Identificador del Zip</param> /// <param name="entryName">Nombre del elemento en el zip</param> /// <param name="FileInBytes">Informacion en Bytes que corresponde al elemento a subir</param> /// <param name="fileMode">Modo del archivo</param> public void AddOrUpdateFile(int identifier, EFileContainer fileContainer, string entryName, byte[] fileInBytes, FileMode fileMode) { var fullFileName = string.Format("{0}_{1}.zip", identifier, fileContainer); var physicalPath = string.Concat(_fileResolver.Resolve(_destinationPath + fileContainer + "/"), fullFileName); using (FileStream zipToOpen = new FileStream(physicalPath, fileMode)) { using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update)) { ZipArchiveEntry readmeEntry = archive.GetEntry(entryName); if (readmeEntry == null) { readmeEntry = archive.CreateEntry(entryName); } using (BufferedStream writer = new BufferedStream(readmeEntry.Open())) { writer.Write(fileInBytes, 0, fileInBytes.Length); } } } }
public string PathResolver(string filePath, EFileContainer fileContainer) { return(string.Concat(_fileResolver.Resolve(_destinationPath + fileContainer + "/"), filePath)); }
public string DomainResolver(string filePath, EFileContainer fileContainer) { var appPath = string.Format("{0}{1}", ServerDomainResolver.GetCurrentDomain(), _destinationPath + fileContainer + "/" + filePath); return(appPath); }
public void Delete(string filePath, EFileContainer fileContainer) { var fileLocation = _fileResolver.Resolve(_destinationPath + fileContainer + "/" + filePath); System.IO.File.Delete(fileLocation); }
public static string UnknownIfIsNullOrEmpty(this string imagePath, EFileType eFileType, EFileContainer eFileContainer) { return(imagePath.IsNullOrEmpty() ? ServerDomainResolver.GetCurrentDomain() + "/Content/Images/System/Unknown" + eFileType + ".png" : Resolver(imagePath, eFileContainer)); }
public static string Resolver(string filePath, EFileContainer fileContainer) { var appPath = string.Format("{0}{1}{2}", ServerDomainResolver.GetCurrentDomain(), FileSettings.ContentFolder, fileContainer + "/" + filePath); return(appPath); }