In the example, I don't see how to create a database that doesn't exist on the hard disk.
So I write these codes (I want to create a new gdb file, instead of visiting a exsiting file, like @"..\..\..\data\sample"):
var path = @"H:\AAAAATEMP\sample3";
//delete the old gdb file
if (File.Exists(path))
{
File.Delete(path);
}
//create a new gdb file
var connection = new DatabaseConnection(path);
var n0 = connection.CreateNode(
new Dictionary<string, string>() { { "Name", "Ken" } },
new HashSet<string>() { "Person" }
);
But the 'CreateNode' throws an "System.IO.IOException".
I download the souce code and debug, and located the the place of error.
Finally, I think the reason is that:
In the new DatabaseConnection(path), it will File.Create(filePath); , but I need to change it to File.Create(filePath).Close();
In the connection.CreateNode(...), it will SaveDatabase()
In the SaveDatabase(), it will File.WriteAllBytes(FilePath, bytes);, but at the moment, the file is occupied by File.Create(filePath);
I'm a beginner. I'm not very good at C#.
I'm a little confused. I'm not sure whether I should revise it like File.Create(filePath).Close();, but it does work well when revising it.
In the example, I don't see how to create a database that doesn't exist on the hard disk. So I write these codes (I want to create a new gdb file, instead of visiting a exsiting file, like
@"..\..\..\data\sample"
):But the 'CreateNode' throws an "System.IO.IOException".
I download the souce code and debug, and located the the place of error.
Finally, I think the reason is that:
new DatabaseConnection(path)
, it willFile.Create(filePath);
, but I need to change it toFile.Create(filePath).Close();
connection.CreateNode(...)
, it willSaveDatabase()
SaveDatabase()
, it willFile.WriteAllBytes(FilePath, bytes);
, but at the moment, the file is occupied byFile.Create(filePath);
I'm a beginner. I'm not very good at C#. I'm a little confused. I'm not sure whether I should revise it like
File.Create(filePath).Close();
, but it does work well when revising it.Thanks.