cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
bidev Frequent Visitor
Frequent Visitor

How to check if a file exists

I have a code that looks the file exists or not before doing further processing.  Result of "try Source" evaluation, Test[HasError] in if statement returns "False" always, whether or not there was a file "MyLog.log" in  the path "C:\Log-Files\Empty-LogFolder\".

Appreciate if you can shed some light on it.  Code below.  Thank you.   

 

***********************************

let
    File_Path = "C:\Log-Files\Empty-LogFolder\MyLog.log",
    Source = Csv.Document(File.Contents(File_Path),[Delimiter=";", Columns=3, Encoding=1252, QuoteStyle=QuoteStyle.None]),
   Test = try Source,
   Output = if Test[HasError] then "True" else "False"
in
   Output

1 ACCEPTED SOLUTION

Accepted Solutions
ankitpatira Super Contributor
Super Contributor

Re: How to check if a file exists

@bidev Check out this post which describes on writing IF ELSE statement in power query.

View solution in original post

2 REPLIES 2
ankitpatira Super Contributor
Super Contributor

Re: How to check if a file exists

@bidev Check out this post which describes on writing IF ELSE statement in power query.

View solution in original post

bidev Frequent Visitor
Frequent Visitor

Re: How to check if a file exists

Thank you, ankitpatira.  Appreciate your help.

Helpful resources

Announcements
New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (3,570)