Following the reference source link in the answer to this question, System.IO.FileStream.Init only throws the NotSupportedException once with the Argument_PathFormatNotSupported string, in the circumstance of an erroneously positioned ":" character.
However, in my code this "The given path's format is not supported" error is thrown even when this condition is not present, e.g.
PHS shape = new PHS();
try
{
string filePath = Path.GetFullPath(Path.GetDirectoryName(Application.ExecutablePath) + "\\..\\..\\Maps\\ne_50m_urban_areas.shp");
if (filePath.IndexOf(':', 2) != -1)
MessageBox.Show("filePath bad");
else
MessageBox.Show("filePath okay");
shape.LoadFile(Populated, filePath);
}
catch (NotSupportedException ee)
{
MessageBox.Show(ee.StackTrace);
}
Running this code first gives me "filePath okay", but then gives me a NotSupportedException with the following stack:
The LoadFile method is calling FileStream via System.IO.File.OpenRead(). What is curious is that this error is thrown only when the filePath is of a certain length - if the filePath is short, the error isn't thrown. This behaviour can be seen on copies of Win10, Win8.1 and Win2003.
Any explanations for this behaviour gratefully received, thank you.