ThinkGeo.com    |     Documentation    |     Premium Support

Sharepoint and UNC Path Errors

Hi,

I have a client that keeps data on a sharepoint file site and maps that location to a network drive on their computer. He tried to load a shapefile from that drive to our product which did not have an .idx file and by default we have coded our software to create the index file. Once the code tried to create the index, we got the following I/O exception error.

In the past, I have found that we can’t load or export data to drives referenced with UNC paths, but in this case he’s mapped the drive. Since the BuildIndexFile() function is part of Mapsuite, we can’t see what path type its using to know if maybe it’s converting it back to UNC to draw the error.

Client can copy files to/from the shared drive through normal windows explorer, so there should be no issue resolving the path.

Also, in my testing with mapped network drives, I can not replicate the issue so potentially it is specific to sharepoint.

This shared resource is very important for the client to keep their data and we need to be able to reference GIS data directly from this drive instead of making local copies on multiple users machines. Any ideas?

We are using version 9 Mapsuite.

Thanks,
Damian

Hi Damian,

Your exception information shows, your code is not build index, it’s build a shape file.

If you want to build index, please call this API: ShapeFileFeatureSource.BuildIndex(“Path”, BuildIndexMode.DoNotRebuild).

If this exception is not easy to reproduce, I think you can build a simple sample to test in your client’s environment to make sure where is the probelm.

Here is related system API we used in the exception is thrown.

string newPathFileName = Path.GetDirectoryName(pathFilename) + "\\TMP" + Path.GetFileName(pathFilename);
// ... create the newPathFileName
File.Move(newPathFileName, pathFilename); // The exception should be thrown here

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

Sorry, I copied the wrong exception info from a similar issue. See attached.

If I understand your code correctly, you are making a TMP directory at the location of the shapefile and then overwriting the original with the File.Move, but it doesn’t show creation of TMP or subsequent deletion of it which I assume is happening. In either case, I believe creating that TMP directory is part of the problem. If my program was not being run using elevated privileges, it may not have the capability to write data to the current directory on the target device.

Regards,
Damian

Hi Damian,

We build TMP files but not TMP directory, and after build complete we rename the file name(Move). That’s necessary when build index file, because if the process get break when it hadn’t completed, you can know it from the file and when you call build index again it will be covered, but if we directly build index file, you cannot know whether it’s complete or not.

And that’s strange, I am not sure why the file create is allowed by the file rename is not, I think the security for them should be the same.

If your machine forbid create new file, our build index cannot works, and I think you can set ShapeFileFeatureLayer.RequireIndex to false, so you don’t need build index for it, but the performance should be bad. One solution for that is in your code build an InmemoryFeatureLayer, get all features from ShapeFileFeatureLayer and put them into the InmemoryFeatureLayer, then add InmemoryFeatureLayer into your map, you can build index for the InmemoryFeatureLayer.

Wish that’s helpful.

Regards,

Ethan