private string CreateTempFile(string path)
        {
            string tempFilePath = PathUtil.GetTempFilePath(path);
            var    info         = _service.CreateFile(tempFilePath);

            return(info.Path);
        }
        private IFileInfo CreateTempFile(string path)
        {
            string    tempFilePath = PathUtil.GetTempFilePath(path);
            IFileInfo info         = _service.GetFile(tempFilePath);

            info = _service.CreateFile(info);

            return(info);
        }
示例#3
0
        private async Task CreateJsonFile()
        {
            var products = await _productRepository.GetAllAsync();

            if (products.Any())
            {
                _jsonFileProvider.CreateFile(products);
            }
        }
 private void OnSaveLayoutAsFile(object sender, EventArgs e)
 {
     using (Stream stream = _fileProvider.CreateFile())
     {
         if (stream == Stream.Null)
         {
             return;
         }
         SaveLayoutToStream(stream);
     }
 }
示例#5
0
        public void SaveSettings(SetupSettings settings, string setupSettingsFilePath)
        {
            _fileProvider.CreateFile(setupSettingsFilePath);

            var serializerSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            };

            var text = JsonConvert.SerializeObject(settings, Formatting.Indented, serializerSettings);

            _fileProvider.WriteText(setupSettingsFilePath, text, Encoding.UTF8);
        }
 public IFileInfo CreateFile(IFileInfo file)
 {
     return(_next.CreateFile(file));
 }
        public object Post([FromBody] dynamic model)
        {
            if (model == null)
            {
                throw new ApiArgumentException("model");
            }
            if (model.parent == null)
            {
                throw new ApiArgumentException("parent");
            }
            if (!(model.parent is JObject))
            {
                throw new ApiArgumentException("parent", ApiArgumentException.EXPECTED_OBJECT);
            }

            //
            // Check Id
            string parentUuid = DynamicHelper.Value(model.parent.id);

            if (parentUuid == null)
            {
                throw new ApiArgumentException("parent.id");
            }

            FileId fileId = FileId.FromUuid(parentUuid);

            if (!_provider.DirectoryExists(fileId.PhysicalPath))
            {
                throw new NotFoundException("parent");
            }

            //
            // Check Name
            string name = DynamicHelper.Value(model.name);

            if (!PathUtil.IsValidFileName(name))
            {
                throw new ApiArgumentException("model.name");
            }

            //
            // Check Type
            string type = DynamicHelper.Value(model.type);

            FileType fileType;

            if (type == null || !Enum.TryParse(type, true, out fileType))
            {
                throw new ApiArgumentException("model.type");
            }

            DateTime?created      = DynamicHelper.To <DateTime>(model.created);
            DateTime?lastAccess   = DynamicHelper.To <DateTime>(model.last_access);
            DateTime?lastModified = DynamicHelper.To <DateTime>(model.last_modified);

            var creationPath = Path.Combine(fileId.PhysicalPath, name);

            if (_provider.DirectoryExists(creationPath) || _provider.FileExists(creationPath))
            {
                throw new AlreadyExistsException("name");
            }

            IFileInfo info = fileType == FileType.File ? _provider.CreateFile(creationPath) : _provider.CreateDirectory(creationPath);

            _provider.SetFileTime(info.Path, lastAccess, lastModified, created);

            dynamic file = _helper.ToJsonModel(info);

            return(Created(FilesHelper.GetLocation(file.id), _helper.ToJsonModel(info)));
        }