/// <summary> /// Read a file as string from a certain location /// </summary> /// <param name="folder">The name of the folder</param> /// <param name="fullName">The name of the file</param> /// <returns>File content as string</returns> public override async Task <string> ReadAsTextAsync(string folder, string fullName) { var fullPath = _fileStore.PathCombine(folder, fullName); var result = await _fileStoreAsync.TryReadTextFileAsync(fullPath).ConfigureAwait(false); return(result.Result); }
public static async Task <string> TryReadTextFileAsync(string folder, string fileFullName) { var fullPath = FileStore.PathCombine(folder, fileFullName); var result = await FileStoreAsync.TryReadTextFileAsync(fullPath).ConfigureAwait(false); return(result.Result); }
public override void AddAttachment(string id, Stream fileStream, string contentType, string attachmentName) { var entityAttachmentDir = fileStore.PathCombine(AttachmentsDirectoryPath, id); var attachmentFilePath = fileStore.PathCombine(entityAttachmentDir, attachmentName); fileStore.EnsureFolderExists(entityAttachmentDir); fileStore.WriteFile(attachmentFilePath, (localFileStream) => fileStream.CopyTo(localFileStream)); }
public GodsService(ISimpleRestService simpleRestService, IMvxFileStore fileStore, IMvxJsonConverter jsonConverter) { _simpleRestService = simpleRestService; _FileStore = fileStore; _JsonConverter = jsonConverter; _Path = _FileStore.PathCombine("SmiteApp", "gods.json"); }
private string GenerateImagePath() { if (PictureBytes == null) { return(null); } var randomFileName = "Image" + Guid.NewGuid().ToString("N") + ".jpg"; _fileStore.EnsureFolderExists("Images"); var path = _fileStore.PathCombine("Images", randomFileName); _fileStore.WriteFile(path, PictureBytes); return(path); }
public string SaveImageToFile(byte[] pictureBytes) { if (pictureBytes == null) { return(null); } var randomFileName = "Image" + Guid.NewGuid().ToString("N") + ".jpg"; _fileStore.EnsureFolderExists("Images"); var path = _fileStore.PathCombine("Images", randomFileName); _fileStore.WriteFile(path, pictureBytes); return(path); }
public void Initialize(string settingFolder, string settingFile) { if (string.IsNullOrEmpty(settingFolder) || string.IsNullOrEmpty(settingFile)) { Debug.WriteLine("Couldn't init empty setting folder and setting file name"); return; } _settingFolder = settingFolder; _settingFile = settingFile; _filePath = _fileStore.PathCombine(_settingFolder, _settingFile); _fileStore.EnsureFolderExists(_settingFolder); if (!_fileStore.Exists(_settingFile)) { return; } if (!_fileStore.TryReadBinaryFile(_settingFile, LoadFrom)) { _resourceLoader.GetResourceStream(_settingFile, inputStream => LoadFrom(inputStream)); } }