Exemplo n.º 1
0
        internal static Stream RetrieveFile(DatabaseInteraction.Models.FileInfo fileInfo)
        {
            try
            {
                string path = fileInfo.GetFilePath();

                var fileName = Path.GetFileName(path);
                return(File.OpenRead(path));

                //byte[] fileBytes = File.ReadAllBytes(path);

                //return new MemoryStream(fileBytes);
            }
            catch (Exception e)
            {
                throw new Exception("Error retrieving the file.", e);
            }
        }
Exemplo n.º 2
0
        internal static bool RemoveFile(DatabaseInteraction.Models.FileInfo fileInfo)
        {
            try
            {
                string path = fileInfo.GetFilePath();

                if (File.Exists(path))
                {
                    File.Delete(path);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        internal static bool SaveFile(DatabaseInteraction.Models.FileInfo fileInfo, byte[] fileBytes)
        {
            try
            {
                string path = fileInfo.GetFilePath();
                CreateDirectoryIfNotExists(path);
                using (var newFileStream = File.Create(path))
                {
                    newFileStream.Write(fileBytes, 0, fileBytes.Length);
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }