Syntax question Directory.GetFiles

Hello,

this line worked fine till today, I started to get the error message “Where is not a member of string”…I need to loop through all excel files not starting with ~ at the beginning of the file

Directory.GetFiles("C:\Users\lynn.song\Desktop\Attachments","*.xlsx",SearchOption.AllDirectories).Where(Function(s) not System.IO.Path.GetFileName(s).StartsWith("~"))

thanks

Hi,
Try this
Directory.GetFiles(“C:\Users\lynn.song\Desktop\Attachments”,“*.xlsx”,SearchOption.AllDirectories).Where (Function(s) not System.IO.Path.GetFileName(s).StartsWith(“~”))

that is not working either

Hi @lynnsong986 - I’ve tried your expression but it’s not throwing any error. Can you please retype/copy the same expression, save it , wait a minute

Yes it works now! weird… thanks so much!

Hi @lynnsong986

Give a try with

System.IO.Directory.GetFiles("C:\Users\lynn.song\Desktop\Attachments","*.xlsx",SearchOption.AllDirectories).Where(Function(s) not System.IO.Path.GetFileName(s).StartsWith("~"))

Make sure that your variable is IEnumerable

Regards!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.