Directory.GetFiles not working with config file

Directory.GetFiles(“C:\Users\Nethan\Desktop\Data\folder”,“allfile*”)

this part is taken from the config file=C:\Users\Nethan\Desktop\Data\folder
this file name should be wildcard =allfile*

im try to use the the config file to import the file path but i m getting an error call Assign: Illegal characters in path.

why is that

So what you’ve written in your post is exactly what you’re putting in your workflow? Because there aren’t any illegal characters in what you’ve written, but I’m not sure what it has to do with a config file?

hi @Dave

config file

in_path = C:\Users\Nethan\Desktop\Data\ folder

so i m trying to access allfile2312.xlmx file which is inside the folder and name of the file should be wildcard
but getting a error

it look like this Directory.GetFiles(in_path”,“allfile*”)

there is a space between the last \ and folder. Maybe that’s the issue? I would double check the in_path to make sure everything is exactly as expected.

The illegal character means you are supplying a filepath that isn’t possible due to characters not allowed in filepaths or filenames: What characters are forbidden in Windows and Linux directory names? - Stack Overflow

This is a separate issue from what you’re getting, but keep in mind that your current wildcard indicator must start with allfile for it to be grabbed by your getfiles method. If you want it to have the word allfile anywhere, you should include the asterisk wildcard at the beginning and end of your filter

1 Like

still not working spaces not the issue

Do you have an asterisk in the filepath in your config? Or any of the illegal characters mentioned in the stackoverflow link I posted?

Can you copy + paste the filepath from your config exacty as it is shown? Make sure to use the preformatted text option here so it will show it exactly how it is in your config. You could also post a screenshot, but that wouldn’t show things like double spaces, tab characters, etc.

i want to get the highlighted part from config file

but when is Directory.GetFiles(in_path”,“allfile*”) get gives me an error

It works when you hardcode it like that, but doesn’t work when you are pulling from the config? Make sure the hardcoded version is copy+pasted from your config file, as that ensures you are testing the correct value

If so, then you just need to debug your code. Simple techniques such as doing putting breakpoints on various points and checking to ensure the value of “in_path” is exactly what you expect at those breakpoints should be sufficient to find your problem.

1 Like

i m getting a backslash \ in middle of data and DNExport091716

C:\Users\netha\Desktop\REAC\data",“DNExport091716*”

and i could not find why

@Tharusha_Fernando, So you want to get all the files from a folder right, then you can use , Directory.GetFiles(“C:\Users\netha\Desktop\REAC\data”) and ensure that data folder is created, contain files.

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