用转义字符格式化字符串
本文关键字:字符串 格式化 转义字符 | 更新日期: 2023-09-27 18:19:04
我花了很长时间尝试在c#中格式化它,并尝试了多种不同的组合(我不会列出它们,因为它会太多!),但都没有成功。有人能帮我一下吗?
我想要的结果:
/记录器"' ' server ' '加元包日志' SSISErrors.txt ' "
我正在尝试使用字符串构建器,但这并没有使工作更容易:
string path = String.Format(@"''{0}'c$'Packages Log'", Environment.MachineName);
StringBuilder buildLogcmd = new StringBuilder();
buildLogcmd.Append("/LOGGER ");
buildLogcmd.Append(String.Format("'"'''" ''{0}''SSISErrors.txt'' '"'"", path));
当前输出:/记录器"' ' ' ' server ' '加元包日志' ' SSISErrors.txt '
string path = String.Format(@"""'""'{0}'c$'Packages Log'", Environment.MachineName);
StringBuilder buildLogcmd = new StringBuilder();
buildLogcmd.Append("/LOGGER ");
buildLogcmd.Append(String.Format(@"{0}SSISErrors.txt'""""", path));
string path = String.Format(@"{0}'c$'Packages Log", Environment.MachineName);
StringBuilder buildLogcmd = new StringBuilder();
buildLogcmd.Append("/LOGGER ");
buildLogcmd.Append(String.Format("'"'''"''{0}''SSISErrors.txt'''"'"", path));