Search for a file in a drive

Want to search a file in a drive i m using this facing error.
Directory.EnumerateFiles(“D:”+"", “*”,SearchOption.AllDirectories)

Can anyone help me out.

Without giving filepath i need to search with filename in D drive

Thanks

1 Like

If it is a single file, use Path exists activity and give the entire path.

1 Like

Thanks for your response…

As i dont know the path i want to search by file name in D drive

If you know the file name then try this

Directory.GetFiles(“E:”,“doc.pdf”,SearchOption.AllDirectories)

Thanks

2 Likes

ok .let me try this

image

i am facing this error.

Please let me know.

Hi @Snehamayi_Sneha

Have you given entire path

Thanks
Ashwin.S

Hi,

I need to search the file by filename not be filepath in D drive.so how to do?

Hi @Snehamayi_Sneha

Check this
Strvar=path.GetFilenamewithoutextension(input path)

Thanks
Ashwin.S

what is Input path here?

Path name of the folder

Thanks
Ashwin.S

No my search criteria is i knew the file name but not file path. I want to search the file in D drive with the file name.
Eg: The file is present in Drive inside a subfolder so how to achieve it without giving the path to search in whole D drive?

Hi @Snehamayi_Sneha

Use directory.get files(“d:/”)

Use for each item in files

And try to print it in log message

Thanks
Ashwin.S

YaThanks for your quick response.

It will get all the files of D drive i am currently using this my filename is hey325.txt
i want to search this file only in D drive
Directory.GetFiles(“D:”,"hey325.txt”,SearchOption.AllDirectories)

1 Like

Hi @Snehamayi_Sneha
Use directory.get files(mention the path of d drive only)

Use for each item loop check it with based on item.tostring.contains(“hey325.txt”)
Then dothe manipulations

Thanks
Ashwin.S

thanks,

I tried it its not getting the folder name and its subfolder as well.only the files present over it it fetch.

Can you please suggest any other idea

Hi @Snehamayi_Sneha

You want to check whether the file is exist in D drive or not right ?
or if file is exist you want to do any thing like get the entire path like that ?

Thanks,
Kalyan.

Thanks…

Ya just i want to know whether the file exist or not its good if i get the path also.

In My situation the file exist inside a subfolder of d drive.

Just i want my bot should identify

okay … in drive D drive only subfolders you need to check or subfolders and also if any folders exist in that subfolders in that also need to check.

I need to check whole D drive where that file exist. If that file present inside a subfolder it should detect the file.

It should check all folders and the subfolders as well

Any idea or suggestion?