Пример #1
0
        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);
 }
Пример #3
0
        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);
        }
Пример #4
0
        /// <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();
                    }
                }
            }
        }
Пример #5
0
        /// <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);
                    }
                }
            }
        }
Пример #6
0
 public string PathResolver(string filePath, EFileContainer fileContainer)
 {
     return(string.Concat(_fileResolver.Resolve(_destinationPath + fileContainer + "/"), filePath));
 }
Пример #7
0
        public string DomainResolver(string filePath, EFileContainer fileContainer)
        {
            var appPath = string.Format("{0}{1}", ServerDomainResolver.GetCurrentDomain(), _destinationPath + fileContainer + "/" + filePath);

            return(appPath);
        }
Пример #8
0
        public void Delete(string filePath, EFileContainer fileContainer)
        {
            var fileLocation = _fileResolver.Resolve(_destinationPath + fileContainer + "/" + filePath);

            System.IO.File.Delete(fileLocation);
        }
Пример #9
0
 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));
 }
Пример #10
0
        public static string Resolver(string filePath, EFileContainer fileContainer)
        {
            var appPath = string.Format("{0}{1}{2}", ServerDomainResolver.GetCurrentDomain(), FileSettings.ContentFolder, fileContainer + "/" + filePath);

            return(appPath);
        }