Пример #1
0
        /// <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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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));
        }
Пример #4
0
 public GodsService(ISimpleRestService simpleRestService, IMvxFileStore fileStore, IMvxJsonConverter jsonConverter)
 {
     _simpleRestService = simpleRestService;
     _FileStore = fileStore;
     _JsonConverter = jsonConverter;
     _Path = _FileStore.PathCombine("SmiteApp", "gods.json");
 }
Пример #5
0
        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);
        }
Пример #6
0
        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));
            }
        }