1
I need to execute mongoimport command from mongoDB via code but not for sure:
`pro.FileName = "cmd.exe";
//pro.UseShellExecute = false;
pro.Arguments = @"/k cd C:\Program Files\MongoDB\Server\3.4\bin\";
Process proStart = new Process();
proStart.StartInfo = pro;
proStart.Start();
I need to execute the mongoimport that is inside the bin, but I cannot.
Someone can help out?
Thank you, however I tried this way and also does not work, but does not prevent error so it is difficult to know what it is, but I called right the executable of mongoimport and passed as argument the command and even so does not work :/
– user75436
Sorry, the code is wrong I’ll make the correction
– Tiago S
Now yes, I took the Soen code and added it to your case and forgot to put the executable. Try this way and check if it solves
– Tiago S
You have to pass the name of the executable
mongoimport.exe
– Tiago S
I did so even passing the mongoimport.exe in filename and it still doesn’t work!
– user75436
The worst is that I can’t reproduce any error that might be occurring
– user75436
If you call straight by the cmd will?
– Tiago S
Yes, by the cmd: I go to Pasa bin and in it I call the mongoimport -d test -c ... and it works normal
– user75436
Test this code on c#
Process.Start(@"C:\Program Files\MongoDB\Server\3.4\bin\mongoimport.exe", @" -d test -c " + collectionName + " --type csv --file " + filepath + " --headerline");
– Tiago S