1 year ago
#303303
JeanBook
how to use mongoimport (from mongotools) in c#
im learning how to connect mongoDB with c#
my objective is to import a student.json file and add it to my db in a new collection using c#
this is what im trying to use :
var command = @"mongoimport --db test --collection colectn2 --file c:\tmp\students.json --jsonArray";
//get database
IMongoDatabase testDB = dbClient.GetDatabase("test");
var result = testDB.RunCommand<BsonDocument>(command);
Console.WriteLine(result.ToJson());
when i try this in my cmd line works fine.
The problem: mongoimport doesnt import the json file when i try to run it from the c# application but it does import it when i use the same statement from the command line.
Your help is highly appreciate it !
c#
mongodb
winforms
mongoimport
0 Answers
Your Answer