Ejemplo n.º 1
0
        public async void RenameFileAsync(string path, string newPath)
        {
            var files = await _bucket.FindAsync(Builders <GridFSFileInfo> .Filter.Empty);

            var fileResult = files.ToList().FirstOrDefault(x => x.Filename == path);

            if (fileResult != null)
            {
                await _bucket.RenameAsync(fileResult.Id, newPath);
            }
        }
Ejemplo n.º 2
0
        public async void ReNameFile(string fileName, string newFileName)
        {
            var filter = Builders <GridFSFileInfo> .Filter.Eq(x => x.Filename, fileName);

            var filesCursor = await _gridFsBucket.FindAsync(filter);

            var files = await filesCursor.ToListAsync();

            foreach (var file in files)
            {
                await _gridFsBucket.RenameAsync(file.Id, newFileName);
            }
        }