Delete() public méthode

Deletes GridFS files.
public Delete ( IMongoQuery query ) : void
query IMongoQuery A query that specifies the GridFS files to delete.
Résultat void
Exemple #1
0
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="remoteFile"></param>
        public void Delete(string remoteFile)
        {
            _logger.DebugFormat("Delete File, Id:{0}", remoteFile);

            try
            {
                MongoGridFS fs = new MongoGridFS(_context.DataBase);
                fs.Delete(remoteFile);

            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _logger.Error(ex.StackTrace);
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// 批量删除文件
        /// </summary>
        /// <param name="files"></param>
        public void Delete(string[] remoteFiles)
        {
            _logger.Debug("Delete Files");

            try
            {
                MongoGridFS fs = new MongoGridFS(_context.DataBase);
                foreach (string item in remoteFiles)
                {
                    fs.Delete(item);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                _logger.Error(ex.StackTrace);
                throw;
            }
        }
Exemple #3
0
 //delete from GridFS (old api)
 public static void deleteFromGridFS(string imeFajla)
 {
     var client = new MongoClient("mongodb://localhost");
     var server = client.GetServer();
     var database = server.GetDatabase("docs");
     var gridFs = new MongoGridFS(database);
     gridFs.Delete(imeFajla);
 }