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