NetTopologySuite/NetTopologySuite.IO.Esri

shpPath paramater in Shapefile.WriteAllFeatures does not work

Closed this issue · 5 comments

No matter what is supplied for shpPath the files are always written to the same directory the executable is in.

can you add some sample code that reproduces the error?

When a path is specified for the shpPath parameter, WriteAllFeatures does not write the files to that path.

Instead, it seems to use the last folder in the path and use this as the filenames, it then writes the files to the same directory the executable is running from.

So there is no way to control where the files are written.

There is no error, it is just not the desired behavior.

image

image

Cheers

The path you uses basically means that you want to create a file named "test" in the CurrentDirectory. This is the expected behaviour because the path parameter must be the path to a file.

You can immedately fix this problem using this procedure:

  1. The path you use must be the path of the shapefile, so don't use Directory.GetCurrentDirectory() + "\\test but use Directory.GetCurrentDirectory() + "\\test\\myshapefile (even better, use Path.Combine to make file paths)
  2. Be sure that the folder exists, before writing a file on it, so something like if !DirectoryExists(Directory.GetCurrentDirectory() + "\test) Directory.Create(Directory.GetCurrentDirectory() + "\\test)

Thanks @DGuidi , an oversight on my part when tired.
I feel a bit silly.

welcome to the team 😉