我有一个平面文件连接管理器。 我使用变量来定义源路径,然后使用表达式组合路径和文件名。 是否有一个函数可以组合路径,即 C# 路径.Combine。 我想防止错误,其中值可能在路径末尾有也可能没有\
如果您愿意使用 expression
来处理检查,那么 follwing 可能会有所帮助,但尚未测试表达式,
RIGHT( @[User::strFilePath] ,1) == "\" ? @[User::strFilePath] + @[User::strFileName] : @[User::strFilePath] + "\" + @[User::strFileName]
它使用表达式ternary operator
来决定是否需要追加在 filePath 的末尾。
更新为使用RIGHT
函数而不是左和反向组合函数。
小清洁工,
@[User::strFilePath] + (RIGHT(@[User::strFilePath] ,1) == "\" ? "" : "\") + @[User::strFileName]
一个替代选项:REPLACE(@[User::strFilePath] + "\" + @[User::strFileName], "\\", "\")