hi guys i want to use “foreach” for each item in a directory with extension .xls and file name starts with “Network Attack”. the condition for .xls is working fine but the condition for file name starts with network attack is not working.
i tried :
item.ToString.StartsWith(“Network Attack Report”)
item.ToString.StartsWith(“Network Attack Report”)=true
Path.GetFileName(item.ToString) = “Network Attack *”
but they dont work
Contains will search for “Network” in the whole string.
But starts with will search for exact “Network” in the start of the string.
Its better to use contains, but if you want to use starts with can you print what value has item.tostring
As @anil5 mentioned, first try to print the value of item.toString and check whether string is started with “network” or not. If it is not started with that word then we can’t use StartsWith method.