Get Files issue

Afternoon All

Getting an error ive not seen before

For Each: Unable to cast object of type ‘System.String’ to type ‘System.IO.FileInfo’.

Any help much appreciated

Type argument should be string.

that just gives me the directory path, im trying just to get the filename

Use this in your loop

Path.GetFilename(file)

And yes when you are using Directory.GetFiles() TypeArgument should be String, this will give you path just pass that to above code

See this

Thanks,
Prankur

1 Like