我正在尝试使用下面的查询获取文件夹内容,并处理错误。但是我仍然得到一个带有警告图标的文本- "DataSource.NotFound:文件或文件夹:我们找不到文件夹“参见下面的M代码:
let
Source = Folder.Files("\\serverpath\Desktop\"),
AlternativeOutput=#table(type table [Name=text,Extension=text,Availability=text], {{"Error", "Error", "Folder not available"}}),
TestForError= try Source,
Output =
if TestForError[HasError] then AlternativeOutput
else Source在输出中
发布于 2018-02-07 08:49:35
这可能是一个错误,这解释了为什么try...otherwise也不能工作。即使我们得到一个DataSource.NotFound错误,HasError字段也返回false。我已经在我们这一端提交了一篇文章来追踪这个问题。
发布于 2020-02-10 15:51:02
您需要使用Table.Buffer在每次尝试/否则尝试时强制计算Folder.Files
= try Table.Buffer(Folder.Files(path1)) otherwise Folder.Files(path2)然后,您可以评估多个路径,例如,如果在具有不同登录凭据的不同计算机上使用相同的onedrive帐户,即在一台pc上使用用户名,但在另一台计算机(例如个人计算机、工作计算机)上使用user.name
= let SourceA = try Folder.Files("C:\Users\Username\OneDrive\Documents\"),
SourceB = try Folder.Files("C:\Users\User.name\OneDrive\Documents\"),
DynamicSource = try Table.Buffer(SourceA[Value])
otherwise Table.Buffer(SourceB[Value])
in DynamicSource https://stackoverflow.com/questions/48637708
复制相似问题