I am programming with ArcObjects and trying to output a raster to a folder path that contains spaces. Before creating the raster I am trying to validate that the destination path is valid. The following call to IsWorkspace() returns false when the path has spaces. Is this by design or a problem? How should one test that a folder is a valid file-based raster workspace?

Dim aType As Type = Type.GetTypeFromProgID("esriDataSourcesRaster.RasterWorkspaceFactory")
Dim obj As System.Object = Activator.CreateInstance(aType)
Dim pWSF As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory = obj
return pWSF.IsWorkspace("C:\MyGISData\My Output Folder")
  • So the code returns true if the workspace location doesn't contain spaces?
    – Dowlers
    Jun 27 '14 at 16:31
  • Yes that's right. Returns True when there are no spaces. The strange thing is that a path with spaces is valid and the remainder of my code works with a path containing spaces. Raster gets generated in folder correctly.
    – narmaps
    Jun 27 '14 at 16:39
  • That looks like a bug to me. Placing the path in quotes is working for all the rest of your code. What if you try making the path a variable and passing that instead of a direct string? i.e. dim sPath = "C:\MyGISData\My Output Folder" return pWSF.IsWorkspace(sPath)
    – Dowlers
    Jun 27 '14 at 16:47
  • I am actually using the variable approach (I chopped up the code a bit to post it here). And I just tried wrapping the path in quotes. I've also tried appending a trailing slash. No joy.
    – narmaps
    Jun 27 '14 at 16:55
  • I just did a quick test with 10.1 ... IWorkspaceFactory.IsWorkspace returns true for both D:\projects\Grid and D:\projects\Gr id ... but only if there are actually rasters in the folder. (an info subfolder is not sufficient). Perhaps a folder is not considered a raster workspace unless it actually contains some raster datasets. Jun 27 '14 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.