我有一个平面文件连接管理器。我使用一个变量来定义源路径,然后使用表达式组合路径和文件名。是否有一个函数可以组合路径,即C# Path.Combine。我希望防止错误的值可能有或可能没有\在路径的末尾
发布于 2014-12-29 19:55:08
如果您愿意使用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]发布于 2014-12-31 07:22:41
另一种选择是:替换(@User::strFilePath+ "\“+ @User::strFileName,"\","\")
https://stackoverflow.com/questions/27694761
复制相似问题