Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

fileinfo

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?

like image 962
Colin Desmond Avatar asked Jul 21 '09 10:07

Colin Desmond


1 Answers

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.

like image 187
galaktor Avatar answered Oct 06 '22 23:10

galaktor