If condition for file is exist or not


I want to check file is exist in Downloads folder or not if exist then set status in database ’ download report ’ else ’ fail ’
Download is folder name
RlodgeName is variable store file names

@yogitagaikwad2206

Instead of starting from Downloads, It is always recommended to give full path of the folder

Let’s say it is in C:\

Then try C:\Downloads\

Hope this may help you

Thanks,
Srini

Hi @yogitagaikwad2206

Use the “File Exist” activity to check the file is exist save the result in the Boolean variable. Use “IF” condition to check the Boolean is true or false. If true then update the database in the “Then” block If it is false update the database in the “Else” block.

Note : In “File Exist activity” give the full path in the “File Path” field.

I Hope it may help you!!

Hi @yogitagaikwad2206
Change Path Type: Folder to File exists then try.

Regards,

Hi @yogitagaikwad2206

Try this approach-

  1. First, use the “Assign” activity to create a variable downloadPath and set its value to the path of the Downloads folder, like this:
    downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\Downloads"

  2. Use the “File.Exists” activity to check if the file exists in the Downloads folder. You can do this by passing the file path (i.e. downloadPath + RlodgeName ) to the “Path” property of the activity.
    File.Exists(downloadPath + RlodgeName)

  3. Use an “If” activity to check the result of the previous step. If the file exists, set the status in the database to “download report”. Otherwise, set it to “fail”.
    If File.Exists(downloadPath + RlodgeName) Then
    'Set status to “download report” in database
    Else
    'Set status to “fail” in database
    End If

That’s it! This workflow will check if the file exists in the Downloads folder and set the status in the database accordingly.

Thanks

Hi @yogitagaikwad2206

The problem is that you are not puttin the entire path, also you missed an slash before the “.xlsm” part

Regards

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