Is there a way to control where the temp files are generated? For instance, I have a shapefile names Layer1.shp, and when building an index file, it writes the TMPLayer1.idx to the root drive. Many of my users don’t have admin privileges to write to the root drives, which causes issues when trying to rebuild index files.
I am looking for a way to default the placement of temporary files to a local directory to the WPF program. Is that possible yet?
Temp Files Directory
Hi Brandon,
Sorry it looks the temp location won’t be changed, in fact we always put the temp file in same folder with data file.
I think if your users can only read the data, could you please pre-build index file for all of your data, you just need create a simple program for that.
If that data is uploaded by your user, I think you can also provide a utility to your users so that they can build index after they upload data.
Regards,
Don
Don… Thanks for the quick response. You say the TMP file should be in the directory where the original is. However, my permissions error labels it as C:\TMPLayer1.idx when my Layer1.idx file is actually located in C:\XX\XX\Layer1.idx. My user is able to have permissions to the \XX\XX directory, but they have been locked out of direct C: access.
As for prebuilding the index. We do prebuild it, but we also clear existing shapefiles, rebuilding existing shapefiles, and create new shapefiles from the client machines with the permissions issues. We have enough users that we cannot prebuild index files individually for operation that requires it, which is why we pushed that responsibility to the client machines.
Plus, there are occasions where some of our users have corrupted their data and their index files. We gave them the power to recreate their materials on demand because half the time they’re miles away from anywhere with an internet connection collecting data.
Our users are uploading data to our servers. Once that is finished, they are clearing their shapefiles and rebuilding. That is where we are running into the permissions issue on the root C: drive.
We are running off version 8.0.0.129. Perhaps this version is different?
Hi Brandon,
I double check the code again, I am sure we generate temp file to in shape file folder and this logic haven’t been changed for long time, so I think the version is not problem.
We get index file path like this:
Path.ChangeExtension(shapePathFilename, “.idx”)
and this is temp file path:
Path.GetDirectoryName(indexPathFilename) + “\TMP” + Path.GetFileName(indexPathFilename)
so I am sure we won’t create the tmp file on root folder.
I think you can do something now:
1. You can login with administrator account and build index file for a big shape file, then see whether the temp file generated under root folder.
2. Please make sure you haven’t set the index path when you call BuildIndexFile API, just use the simplest one BuildIndexFile is OK.
Any news please let me know.
For workaround, do you think create a service on server to check index file and build index file is viable if the security issue cannot be solved?
Regard,
Don
Don… I checked with the process on my local system where I am an administrator, and I do see the file generating in the same directory. That part is true for what you said. I wonder if the generation on the root drive has something to do with the Path module and how the application permissions play into it. I believe right now we are able to open the program as administrator and not have the issue. However, I am not sure if someone somewhere may find that a security issue sometime. So, we were looking for a disconnected option that would work whenever a limited user needs it to. The way I have it set is ShapefileFeatureSource.BuildIndexFile(pathToShapefile, BuildIndexMode.DoNotRebuild
. There are other processes that pretty much mimic that throughout the application.
If you have any other thoughts, please let me know. Thanks!
Hi Brandon,
I did some research but haven’t found related topics talk about whether the API under “Path” will access root driver, and for some reason I cannot test that in local machine, so if you have more detail information about that please let me know.
I have a question here, it looks you are using WPF edition and that should have a client app run on user’s machine, which means they can build index file before upload data or modified data, do you think we can move build index part to user’s machine?
If I get any thought about that I will let you know.
Regards,
Don