0

目前正在研究 Blue Prism V5.0,现在我正在使用 BP 中的代码块,现在我的目标是获取给定文件夹/路径中的所有文件名。为此,我使用 C# 代码。

String[] str = Directory.GetFiles(inputFolderPath);

为此,我通过相同的代码块提供输入文件/文件夹路径,文件的输出默认为字符串,但 BP 没有字符串类型,因此,如何将数据类型字符串转换为集合。

任何建议都会有所帮助。

提前致谢

4

2 回答 2

2

好吧,有一个标准的 BluePrism 动作可以做到这一点!

Object: Utility - File Management
Action: Get Files

它非常好,因为它确实输出了很多列,包括:文件名和文件路径、扩展名、大小等等。

它还允许过滤结果。示例可能是“.*pdf”,它应该强制操作只返回具有该扩展名的文件。

于 2018-04-10T07:29:07.590 回答
1

将输出添加到 Collection ( System.Data.DataTable) 类型的代码阶段。然后,String[]手动将其转换为 DataTable:

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 工作流程时,您将在“文本”数据类型的输出集合中拥有一列。

于 2018-04-09T20:45:19.157 回答