Hi, I did a TryCatch it catchs file not found exception i’m wondering Is there any possibility to grab that file name and put it in the message box when I get the warning that it could not find the file in this path?
without try catch you’ll get!
did you tried that?
i didnt try. there is a loop its looking for files if there is not a file its giving error because of that i have to use try catch also if i can i want to take that file name to how can i do that?
@mgokcek - Are you assigning the filename to any specific variable? if not - try to create a variable and assign the filePath. Use the same file path in exception section to log the file.
but i have a big data and i dont know do i have that file or not when i get the exception i figure out there is no file. i cant assign every file there is not.
you can do a precautionary check with ‘PathExists’ activity -> select ‘File’ and pass the file path -> it will check and return a Boolean True/False… based on results - false log the file name which is not existed True - continue your process. It will eliminate extra try/catch exception.
This must be the solution for other scenarios. in my project i’m doing filename changes changing their names according to the data stored in excell file. in excell there is an oldName and newName columns for loop is looking that oldname checking if there is a file if there is chageing the name if there isnt giving error i want to use try catch take that name and give some message box “Couldnt change this file name” do i have a chance to do that?
Since you’re doing a rename, I figure you must be using Move file to the same location but with a different name? If the file is not there, is should give you a FileNotFoundException. Put your activity in the Try box, and in the Catch box, set the exception type to FileNotFoundException. Inside it, use a “Message Box” activity with the text being “The file “+row.Item(“oldName”).ToString+” was not found.”
P.S. I have assumed you have read the excel file to a datatable and used the For Each Row activity to iterate through it.
@mgokcek - for file rename - are you using Move File activity? and giving new/old file with same directory? in the foreach try catch block add excel Couldnt change this file name + row('oldName '),ToString
How could I not think of such a simple thing Thank you so much
You’re welcome. Happy coding.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.