I'm writing a Desktop Add-In that scans our directories and pulls in georeferenced raster images that contain a point geometry. While it's been working on many image file types so far for some reason I get the HRESULT E_FAIL error when I get to these files via IEnumDataset.Next():

enter image description here

private static void PullImages(IPoint centerpoint, string directoryPath)
    IWorkspace ws; IDataset dataset; IRasterDataset rasterDataset; IRasterLayer rasterLayer;
    ws = RWSF.OpenFromFile(directoryPath, 0);
    IEnumDataset enumDataset = ws.get_Datasets(esriDatasetType.esriDTRasterDataset);
    dataset = enumDataset.Next();

    while (dataset != null)
        rasterDataset = (ws as IRasterWorkspace).OpenRasterDataset(dataset.BrowseName);
        IEnvelope rasterEnvelope = (rasterDataset as IGeoDataset).Extent;
        if ((rasterEnvelope as IRelationalOperator).Contains(centerpoint))
                rasterLayer = new RasterLayerClass();
                RemoveHistogramStretchAndMinimize(ref rasterLayer);
        dataset = enumDataset.Next();
  • Have you tried it with just the sid file only? – Hornbydd Feb 14 '17 at 23:21
  • I tried moving just the sid file to a test folder and passing its path to the method, but I got the same HRESULT E_FAIL error. I'm also not able to pull the sid into ArcMap with either the extra files or on its own. – cevondanady Feb 14 '17 at 23:32
  • I don't think you need to call OpenRasterDataset. Have you tried casting dataset to rasterDataset instead? Also how are you creating RWSF? I've always wondered what sort of errors occur when you don't follow Esri's advice to use Activator.CreateInstance to create the workspacefactory. – Kirk Kuykendall Feb 15 '17 at 0:49
  • If you cannot even load the sid file into ArcMap would suggest the sid file is corrupt in some way and your code is OK? – Hornbydd Feb 15 '17 at 12:33
  • @Hornbydd I think you are correct, I should have tested that beforehand. I still get other errors on files that I can pull in but I will start another thread. – cevondanady Feb 15 '17 at 15:14

The files shown in the screenshot above were corrupt.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.