目前正在开发 Blue Prism V5.0,现在我正在使用 BP 中的代码块,现在我的目标是获取给定文件夹/路径中的所有文件名。为此,我使用的是 C# 代码。
String[] str = Directory.GetFiles(inputFolderPath);
为此,我通过相同的代码块提供输入文件/文件夹路径,默认情况下文件的输出是字符串,但BP没有字符串类型,因此如何将数据类型字符串转换为集合。
任何建议都会有所帮助。
提前致谢
嗯,有标准的BluePrism动作可以做到这一点!
Object: Utility - File Management
Action: Get Files
这非常好,因为它确实输出了很多列,包括:文件名和文件路径,扩展名,大小等。
它还允许过滤结果。示例可以是".*pdf",它应该强制操作仅返回具有该扩展名的文件。
将输出添加到集合 (System.Data.DataTable
( 类型的代码阶段。然后,手动将String[]
转换为数据表:
outputCollection = new DataTable(); // might not be necessary as Blue Prism will generally instantiate the instance for you; remove this line if you're receiving compiler warnings/errors
// create a column to store your paths
DataColumn col = new DataColumn();
col.DataType = System.Type.GetType("System.String")
col.ColumnName = "Filename";
outputCollection.Columns.Add(col);
// loop through the String[] array and place the values in the DataTable structure
foreach (String el in str) {
DataRow row = outputCollection.NewRow();
row["Filename"] = el;
outputCollection.Rows.Add(row);
}
当此数据输出回您的 Blue Prism 工作流程时,您的"文本"数据类型的输出集合中将有一列。