Forum Discussion

bidev's avatar
bidev
Frequent Visitor
8 years ago
Solved

Gracefully trap Folder Not Found Error

I tried to trap like below, but not working.  Run time error still produced.  Any help would be appreciated.  Thank you.

 

Source = Try Folder.Files("C:\nodirectory"),

output = if Source[HasError] then "Error" else "Good"

 

  • Anonymous's avatar
    Anonymous
    8 years ago

    bidev

    Please use the following code .

    let
        FolderPath = "C:\nodirectory", 
        Test = try List.Count(Folder.Files(FolderPath)[Content]),
        Source = if Test[HasError] then "Cannot find Data Source" else Folder.Files(FolderPath)
    in
        Source



    Regards,
    Lydia

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    bidev

    Please use the following code .

    let
        FolderPath = "C:\nodirectory", 
        Test = try List.Count(Folder.Files(FolderPath)[Content]),
        Source = if Test[HasError] then "Cannot find Data Source" else Folder.Files(FolderPath)
    in
        Source



    Regards,
    Lydia

    • bidev's avatar
      bidev
      Frequent Visitor

      Lydia,

       

      Thank you very much for the solution.  It works perfectly!