Quantcast
Channel: All Power Query posts
Viewing all articles
Browse latest Browse all 122259

How to check if a file exists

$
0
0

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


Viewing all articles
Browse latest Browse all 122259

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>