geodabase file

167
1
01-03-2019 06:54 PM
Highlighted
New Contributor

Hello,

I need to generate Geodabase file (not database but file on filesystem).

Can anyone advise how it can be done within a java application?

Thanks in advance.

Reply
0 Kudos
1 Reply
Highlighted
Occasional Contributor

I can't give a working Java code, but in C# it looks like this (below). However, it won't create a file, the result is a folder. It is a totally empty GDB.

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Geodatabase CreateFileGDB(string GDBPath)
{

// Test the argument:

const string NameOfGDBPath = nameof(GDBPath);
if (string.IsNullOrWhiteSpace(GDBPath))
throw new ArgumentNullException(NameOfGDBPath, "Geodatabase path cannot be null; empty or whitespace-only string.");

DirectoryInfo directoryInfo = new DirectoryInfo(GDBPath);

if (!directoryInfo.Parent.Exists)
throw new DirectoryNotFoundException("The parent directory (" + directoryInfo.Parent.FullName + ") was not found!");

if (directoryInfo.Exists)
directoryInfo.Delete(true);

//Create the GDB:

return Geodatabase.Create(directoryInfo.FullName);
}

Reply
0 Kudos