当前位置: 首页>>代码示例>>C#>>正文


C# MongoDatabase.GetGridFS方法代码示例

本文整理汇总了C#中MongoDatabase.GetGridFS方法的典型用法代码示例。如果您正苦于以下问题:C# MongoDatabase.GetGridFS方法的具体用法?C# MongoDatabase.GetGridFS怎么用?C# MongoDatabase.GetGridFS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MongoDatabase的用法示例。


在下文中一共展示了MongoDatabase.GetGridFS方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MongoReaderPlugin

 /// <summary>
 ///     Create a MongoReaderPlugin with an existing MongoDatabase and specific settings for GridFS
 /// </summary>
 /// <param name="prefix">The virtual folder representing GridFS assets</param>
 /// <param name="db">An existing MongoDatabase instance</param>
 /// <param name="gridSettings">
 ///     Settings for the GridFS connection
 ///     <see href="http://api.mongodb.org/csharp/1.8/html/7a3abd48-0532-8e7f-3c05-6c9812eb06f8.htm" />
 /// </param>
 public MongoReaderPlugin(string prefix, MongoDatabase db, MongoGridFSSettings gridSettings)
 {
     _db = db;
     _gridSettings = gridSettings;
     _grid = _db.GetGridFS(gridSettings);
     VirtualFilesystemPrefix = prefix;
 }
开发者ID:eakova,项目名称:resizer,代码行数:16,代码来源:MongoReaderPlugin.cs

示例2: TestFixtureSetup

 public void TestFixtureSetup() {
     server = MongoServer.Create("mongodb://localhost/?safe=true");
     database = server["onlinetests"];
     var settings = new MongoGridFSSettings {
         ChunkSize = 16,
         SafeMode = SafeMode.True
     };
     gridFS = database.GetGridFS(settings);
 }
开发者ID:simi--,项目名称:mongo-csharp-driver,代码行数:9,代码来源:MongoGridFSStreamTests.cs

示例3: MongoGridFSStreamTests

 public MongoGridFSStreamTests()
 {
     _database = LegacyTestConfiguration.Database;
     var settings = new MongoGridFSSettings
     {
         ChunkSize = 16,
         WriteConcern = WriteConcern.Acknowledged
     };
     _gridFS = _database.GetGridFS(settings);
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:10,代码来源:MongoGridFSStreamTests.cs

示例4: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _server = Configuration.TestServer;
     _database = Configuration.TestDatabase;
     var settings = new MongoGridFSSettings
     {
         ChunkSize = 16,
         SafeMode = SafeMode.True
     };
     _gridFS = _database.GetGridFS(settings);
 }
开发者ID:nilayparikh,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoGridFSStreamTests.cs

示例5: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _server = Configuration.TestServer;
     _database = Configuration.TestDatabase;
     var settings = new MongoGridFSSettings(_database)
     {
         ChunkSize = 16,
         WriteConcern = WriteConcern.Errors
     };
     _gridFS = _database.GetGridFS(settings);
 }
开发者ID:subbuballa,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoGridFSStreamTests.cs

示例6: GridFS

 public GridFS(MongoDatabase database)
 {
     _mongoGridFS = database.GetGridFS(new MongoGridFSSettings());
 }
开发者ID:vmaron,项目名称:Arcnet.MongoDB.Framework,代码行数:4,代码来源:GridFS.cs

示例7: DownloadFile

 /// <summary>
 ///     下载文件
 /// </summary>
 /// <param name="strLocalFileName"></param>
 /// <param name="strRemoteFileName"></param>
 /// <param name="mongoDb"></param>
 public static void DownloadFile(string strLocalFileName, string strRemoteFileName, MongoDatabase mongoDb)
 {
     var gfs = mongoDb.GetGridFS(new MongoGridFSSettings());
     gfs.Download(strLocalFileName, strRemoteFileName);
 }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:11,代码来源:GFS.cs

示例8: DelFile

 /// <summary>
 ///     删除文件
 /// </summary>
 /// <param name="strFileName"></param>
 /// <param name="mongoDb"></param>
 public static void DelFile(string strFileName, MongoDatabase mongoDb)
 {
     var gfs = mongoDb.GetGridFS(new MongoGridFSSettings());
     gfs.Delete(strFileName);
 }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:10,代码来源:GFS.cs

示例9: UpLoadFile

 /// <summary>
 ///     上传文件
 /// </summary>
 /// <remarks>Mongo允许同名文件,因为id才是主键</remarks>
 /// <param name="strFileName"></param>
 /// <param name="option"></param>
 /// <param name="mongoDb"></param>
 public static UploadResult UpLoadFile(string strFileName, UpLoadFileOption option, MongoDatabase mongoDb)
 {
     var gfs = mongoDb.GetGridFS(new MongoGridFSSettings());
     string remoteName;
     if (option.FileNameOpt == EnumGfsFileName.Filename)
     {
         remoteName = new FileInfo(strFileName).Name;
     }
     else
     {
         remoteName = option.DirectorySeparatorChar != Path.DirectorySeparatorChar
             ? strFileName.Replace(Path.DirectorySeparatorChar, option.DirectorySeparatorChar)
             : strFileName;
     }
     try
     {
         MongoHelper.OnActionDone(new ActionDoneEventArgs(remoteName + " Uploading "));
         if (!gfs.Exists(remoteName))
         {
             gfs.Upload(strFileName, remoteName);
             return UploadResult.Complete;
         }
         switch (option.AlreadyOpt)
         {
             case EnumGfsAlready.JustAddIt:
                 gfs.Upload(strFileName, remoteName);
                 return UploadResult.Complete;
             case EnumGfsAlready.RenameIt:
                 var extendName = new FileInfo(strFileName).Extension;
                 var mainName = remoteName.Substring(0, remoteName.Length - extendName.Length);
                 var i = 1;
                 while (gfs.Exists(mainName + i + extendName))
                 {
                     i++;
                 }
                 gfs.Upload(strFileName, mainName + i + extendName);
                 return UploadResult.Complete;
             case EnumGfsAlready.SkipIt:
                 return UploadResult.Skip;
             case EnumGfsAlready.OverwriteIt:
                 gfs.Delete(remoteName);
                 gfs.Upload(strFileName, remoteName);
                 return UploadResult.Complete;
             case EnumGfsAlready.Stop:
                 return UploadResult.Skip;
         }
         return UploadResult.Skip;
     }
     catch (Exception ex)
     {
         Utility.ExceptionDeal(ex);
         return UploadResult.Exception;
     }
 }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:61,代码来源:GFS.cs

示例10: OpenFile

        /// 在使用GirdFileSystem的时候,请注意:
        /// 1.Windows 系统的文件名不区分大小写,不过,filename一定是区分大小写的,如果大小写不匹配的话,会发生无法找到文件的问题
        /// 2.Download的时候,不能使用SlaveOk选项!
        /// <summary>
        ///     打开文件
        /// </summary>
        /// <param name="strRemoteFileName"></param>
        /// <param name="mongoDb"></param>
        public static void OpenFile(string strRemoteFileName, MongoDatabase mongoDb)
        {
            var gfs = mongoDb.GetGridFS(new MongoGridFSSettings());

            var strLocalFileName = strRemoteFileName.Split(Path.DirectorySeparatorChar);

            try
            {
                if (!Directory.Exists(TempFileFolder))
                {
                    Directory.CreateDirectory(TempFileFolder);
                }
                var localFileName = TempFileFolder + Path.DirectorySeparatorChar +
                                    strLocalFileName[strLocalFileName.Length - 1];
                gfs.Download(localFileName, strRemoteFileName);
                Process.Start(localFileName);
            }
            catch (Win32Exception ex)
            {
                Utility.ExceptionDeal(ex, "No Program can open this file");
            }
            catch (Exception ex)
            {
                Utility.ExceptionDeal(ex, "Error", "Exception happend when open file");
            }
        }
开发者ID:lizhi5753186,项目名称:MongoCola,代码行数:34,代码来源:GFS.cs

示例11: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _database = Configuration.TestDatabase;
     var settings = new MongoGridFSSettings
     {
         ChunkSize = 16,
         WriteConcern = WriteConcern.Acknowledged
     };
     _gridFS = _database.GetGridFS(settings);
 }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:10,代码来源:MongoGridFSStreamTests.cs

示例12: OpenFile

 /// 在使用GirdFileSystem的时候,请注意:
 /// 1.Windows 系统的文件名不区分大小写,不过,filename一定是区分大小写的,如果大小写不匹配的话,会发生无法找到文件的问题
 /// 2.Download的时候,不能使用SlaveOk选项!
 /// <summary>
 ///     打开文件
 /// </summary>
 /// <param name="strRemoteFileName"></param>
 /// <param name="mongoDb"></param>
 public static void OpenFile(string strRemoteFileName, MongoDatabase mongoDb)
 {
     var gfs = mongoDb.GetGridFS(new MongoGridFSSettings());
     var strLocalFileName = strRemoteFileName.Split(Path.DirectorySeparatorChar);
     if (!Directory.Exists(TempFileFolder))
     {
         Directory.CreateDirectory(TempFileFolder);
     }
     var localFileName = TempFileFolder + Path.DirectorySeparatorChar +
                         strLocalFileName[strLocalFileName.Length - 1];
     gfs.Download(localFileName, strRemoteFileName);
     Process.Start(localFileName);
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:21,代码来源:GFS.cs


注:本文中的MongoDatabase.GetGridFS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。