Consider the following code
Button["Import", file = SystemDialogInput["FileOpen"];
data = Import[file], Method -> "Queued"]
which yields a button which, upon clicking, opens a directory window from which I can access my files and import one. However, in Windows 10, if I click "Cancel", that is,
I get back the following message, regarding $Canceled
,
How do I avoid such a message? That is, if I click "Cancel" I want both file
and data
to remain non attributed.
I thought about simply checking whether data
or file
are Unevaluated[Sequence[]]
, but not sure how to do this or if there is a better way of doing it.
Any ideas?