加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在powershell中保存XML文件需要完整路径 为什么?

发布时间:2020-12-16 08:06:24 所属栏目:百科 来源:网络整理
导读:我使用powershell的XML功能修改.config文件。 调用XMLDocument.Save没有任何效果,除非我提供完整的路径名。 # Open the xml file$config = [xml](get-content web.config)## modify the XML$config.SelectNodes("./configuration/connectionStrings/add[@na
我使用powershell的XML功能修改.config文件。
调用XMLDocument.Save没有任何效果,除非我提供完整的路径名。
# Open the xml file
$config = [xml](get-content web.config)
#
# modify the XML
$config.SelectNodes("./configuration/connectionStrings/add[@name='LocalSqlServer']") | % { $connNode = $_ }
$connNode.connectionString = $connNode.connectionString -replace '^(.*)Server=[^;]+(.*)$','$1Server=192.168.5.2$2'
#
#
# Now I save it again
#
# This doesn't save it!
$config.Save("web.config");
# However,this works
$config.Save("{0}web.config" -f (get-location));

为什么$ config.Save(“web.config”)工作?

我最后把它保存到别的地方,而不是我的本地目录?

如果没有去当前的工作目录,我会检查$ home。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读