Download problem

In my Automation, at a moment I need to download it, so after using the click tool and downloading the file, I have to make this file create a folder for it, if it doesn’t have one, is there any activity that I can use to do this?

Do this before you start the download.

image

If you can select the folder before the file is downloaded, then you could:

  • Use “Folder Exists” activity
  • Use an If statement to check if the folder exists or not
  • Use “Create Folder” activity if it doesn’t exist

If you cannot control this, you could:

  • Use “Wait for Download” activity based on the click of the download button
  • Once the file is downloaded, use “Folder Exists” activity
  • Use an If statement to check if the folder exists or not
  • Use “Create Folder” activity if it doesn’t exist
  • Use “Move File” activity to move the downloaded file to the new folder

use create folder activity

pass in the directory of your path by passing in:
Path.GetDirectoryName(yourDownloadPath)

I am getting this error “If: Object reference not set to an instance of an object.”


I am getting this error “If: Object reference not set to an instance of an object.”


[/quote]

can you remove this

+ in_transactionItem("....")
in the if statement and the create folder activity?

your in_transactionItem has no value and also you just need to check the directory not the full path

Can you please post here the whole value of the If condition?
I assume that in_transactionItem("....") contains the folder name for the downloaded file, right? If that’s the case, you need to check if it has a value, and also that in_transactionItem is not Nothing.

Eventually add some extra checks in the IF condition, for example: in_transactionItem IsNot Nothing AndAlso in_transactionItem("....") IsNot Nothing

the condition if :
“(“C:\PASTA_COMPARTILHAMENTO\RPA” + in_TransactionItem(“CNPJ”).ToString+”-“+in_TransactionItem(“COMPANY”).ToString)”
I use this condition because the process will enter several companies and extract the report and I want it to create a folder to put each report in a folder with the cnpj and the company

Are the values of in_TransactionItem(“CNPJ”) and in_TransactionItem(“COMPANY”) always expected to be set ? If that’s the case, you should launch your process in Debug mode and investigate why at least one of them was empty when you ran it.

Is this code in a separate XAML that is being called with Invoke Workflow, and you’re passing in in_TransactionItem? If so, you can’t just run that XAML on its own, in_TransactionItem won’t have a value.

You should get in the habit of using Path.Combine instead of + to make paths.

Path.Combine("C:\PASTA_COMPARILHAMETO\RPA",in_TransactionItem(“CPNJ”).ToString + “-” in_TransactionItem(“COMPANY”).ToString)

The purpose of this is it won’t matter if you have the \ characters correctly placed, Path.Combine will manage that for you.