我在PC-BSD 10.1上使用MonoDevelop并使用MongoDB 3.2.我从Nuget下载了MongoDB.Driver(+ Bson&Core).我可以进行基本的读写操作,并试图通过遵循StackOverflow中最新的示例来使GridFS工作:
使用C#的MongoDB GridFs,如何存储图像等文件?
首先,我的系统无法识别(貌似)静态MongoServer类,因此我切换到MognoClient来获取数据库.然后我得到以下内容:
"类型MongoDB.Driver.IMongoDatabase' does not contain a definition forGridFS的'没有扩展方法GridFS' of typeMongoDB.Driver.IMongoDatabase’可以找到."
using System;
using System.IO;
using MongoDB;
using MongoDB.Driver;
using MongoDB.Driver.Core;
using MongoDB.Bson;
//using MongoDB.Driver.GridFS; -> an attempt to use the legacy driver.
namespace OIS.Objektiv.SocketServer
{
public class Gridfs
{
public Gridfs ()
{
var server = MongoServer.Create("mongodb://localhost:27017");
var database = server.GetDatabase("test");
// var client = new MongoClient("mongodb://localhost:27017");
// var database = client.GetDatabase("test");
var fileName = "D:\\Untitled.png";
var newFileName = "D:\\new_Untitled.png"; …Run Code Online (Sandbox Code Playgroud)