Path Checks-If Decision

If you look closely, the error happens at Source: Assign my file to display it

If you look at the activity with this name, you will see a simple assign an Array element to a string variable MyFile:
image

Now, the error says: Index was out of range
So this would mean that the index 0 of our array Newest_File_Check has no value. Because it is the index of the first element of the array, it means that the array is empty.

We can therefore conclude that the search did not return any results and the array is empty.

Do you have any files in the folder and is the path to the folder correct?

Yes,

Currently there have 4 files in mentioned path and i want to choose the latest/newest file from 4files.
image

In this case, I would suggest checking the string in your search function:
directory.GetFiles("*usb201807101424_ポリシーIDなし_完全一致_20180711.csv").Where(function(file) file.LastWriteTime.Date= DateTime.Now.Date).OrderByDescending(function(d) d.LastWriteTimeUtc).ToArray

Maybe make it more broad as a test?
directory.GetFiles("*.csv").Where(function(file) file.LastWriteTime.Date= DateTime.Now.Date).OrderByDescending(function(d) d.LastWriteTimeUtc).ToArray

I have tried to create another files and folder but using the same function (just changed the file/path name}
and the same message of workflow exception appeared.

Yes, indeed. I looked closer at the function and the issue is here:
.Where(function(file) file.LastWriteTime.Date= DateTime.Now.Date)

This bit will only return you a list of files that were modified today :slight_smile:
This means that you will not get the files from your current folder, as those were modified 20 days ago.

Try a simple fix:
.Where(function(file) file.LastWriteTime.Date<= DateTime.Now.Date)

It should, at last, return what you want :smiley:

Thanks, the exception disappeared:grin::grin::+1:

I would like to know, how can I open / call that file to be displayed?
Is it possible?

Please advise.
Thanks

Hi @loginerror ,

I had using Data Scraping function to extract the data from website.
Could you advise on how can i open the extract structured Data table by CSV or Excel?

<?xml version="1.0" encoding="utf-16"?>TrueFalse__ReferenceID0

Please help.
Thanks

You can save your Data Table using Write CSV Activity :slight_smile: You should provide it with the output DataTable from data scraping.

Hi @loginerror ,

Thanks for the advise.
This message appeared after run the Write CSV activity mentioned the the path is denied.


I have checked the security/access permission of the folder itself and no found any restriction.
May I know why this is happened?Below screenshot is the Write CSV activity that i have made.

Please advise,
Thanks

Maybe running the studio with administrator privileges would help here? Assuming it is the system that blocks a save activity. Maybe try to save as a test on your desktop.

Hi @loginerror,

The same Workflow exception is appeared even though i saved the folder to desktop or D drive.
Do you happened to receive or face the similar issue like mine?
Folder security level also has been changed as administrator privilege.

Please advise.
Thanks in advance.

Hi All,

Could I have a support or further advise from your end as per previous issue?
Much appreciated.