Colin Desmond
Colin Desmond

Reputation: 4854

Why are we getting “The path is not of a legal form” for a FileInfo constructor?

We're creating a FileInfo object in C# using the following code:

if (planConfig->OrganisationsFilePath != nullptr)
{
   FileInfo^ file = gcnew FileInfo(planConfig->OrganisationsFilePath);
   //Do some stuff here
}

and our customers are reporting that they see an ArgumentException with “The path is not of a legal form” as the message being thrown. We cannot reproduce this and we're wondering what string you'd need to pass to the FileInfo constructor to see this error?

Upvotes: 7

Views: 41158

Answers (1)

galaktor
galaktor

Reputation: 1527

The path probably contains invalid characters. See the MSDN documentation on FileInfo constructor.

ArgumentException:The file name is empty, contains only white spaces, or contains invalid characters.

Upvotes: 10

Related Questions