Esempio 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);
            }
        }
Esempio 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);
            }
        }
Esempio 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);
        }