Search for the File Name without giving Full Path

Hii,
I have a textFile and i want my BOT to get the file by just the name.
User should not provide the full path.But when User is providing just the File name BOT is throwing an error.
e.g. in Input Dialog user gives just file name like “abc” so BOT should be able to open the File with the name “abc” stored in the computer. User should not give full path like “C:\Users\Desktop\abc.txt”.
Any way to resolve this??
@ddpadil @SaranyaKishore

1 Like

Hi,

Does all the files stored in the specific folder or anywhere in the system?

1 Like

read file that same folder project uipath

regards

1 Like

It can be in the specific folder as well anywhere in the system

1 Like

please elaborate

1 Like

As @Chinh_Le mentioned, if all the files are inside the same folder where the project is present, there is no need to get full path from the user. Only the file name is sufficient to open the file.

1 Like

wht if its present anywhere in the system?
In my scenario it can be present anywhere in the system.
Please help…its urgent
@SaranyaKishore

In my case it can be anywhere in the system

Any Suggestions???

Hi Sowmya,

You can loop through all the logicaldrives (C:\ D:\....) using DriveInfo.GetDrives to check if the file exists or not in that drive.

Syntax :

Directory.GetFiles(driveName,FileName,SearchOption)

The above said has to be placed within a for each loop. But do remember that an access check\ device ready status (System.Io.Exception) has to be performed before making the search in the particular drive using Drive.IsReady.

Note: Not sure about other best and concise solutions. Let’s wait for others as well.

can you please provide it in the form of xaml.Its bit urgent

Hi,

If you are using latest version of UiPath studio then use invoke code activity and place this code inside that.

This code will check entire system for a specified file.

My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.SpecialDirectories.MyDocuments, Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, “yourfilename.”)

Hi,
In my option, in case search file in all folders, this action is very low.
And have case same name but not same path, how do u know this is your file u want?

I think u should focus to save file to predefined directory before read file.

regards

hii,
my file name is of .txt and i want to change it in Excel.
So what i want is,
User will give the filename in Input Dialog ,BOT will search for the file in the system,Convert it into excel and if the file is not present it will throw an exception “File not found”
All this needs to be in Try Catch.
Any suggestions on this?
@sarathi125 @SaranyaKishore @Saurabh_Sahu

@Manjuts90 pls check my this Query and help.

@somya177 below code is not working for u

nope…can u pls share it as workflow on how to use it

@somya177 try below code, it may help u but i not sure.

Main.xaml (11.0 KB)

Below is the error i got :
For each : The device is not ready.\r\n

@somya177

I am not sure about this error