I'm using version 5.0.0.0 of the services edition to prototype at the moment. In testing some of the prototype functionality which checks to see if the server application can open a raster layer (in this case an ECW) the file does not seem to be unlocked when the layer is closed.
In regard to the below code, have I missed anything? RasterLayer etc don't inherit from IDisposable so that's not an option. We'll be doing this same sort of thing with a number of other raster layer types as well.
The below code exhibits the issue:
public void TestLockedFile()
{
var filePath = Path.Combine(m_currentPath, Guid.NewGuid().ToString() + ".ecw");
try
{
File.WriteAllBytes(filePath, Resources.testECW);
var layer = new EcwRasterLayer(filePath);
}
finally
{
File.Delete(filePath); // this works fine
}
try
{
File.WriteAllBytes(filePath, Resources.testECW);
var layer = new EcwRasterLayer(filePath);
layer.Open();
layer.Close();
}
finally
{
File.Delete(filePath); // this fails as the file is locked by another process
}
}
Any thoughts?