- set fso=CreateObject("Scripting.FileSystemObject")
- set ws=CreateObject("wscript.shell")
- filename="123.txt"
- ansi2utf8 filename,"utf-8","gbk","temp.tmp"
- set fr=fso.opentextfile("temp.tmp",1,-1)
- set fw=fso.createtextfile("temp2.tmp",2)
- Set regEx = New RegExp
- do
- data=fr.readline
- regEx.Pattern = "<add key=""UseSecLCD"" value=""N"" />"
- data = regEx.Replace(data, "<add key=""UseSecLCD"" value=""Y"" />")
- fw.writeline data
- loop until fr.atendofstream
- fw.close:fr.close
- ansi2utf8 "temp2.tmp","gbk","utf-8",filename
- fso.deletefile "temp.tmp",true
- fso.deletefile "temp2.tmp",true
- function ansi2utf8(strFile,s1,s2,newname)
- Set ADOStrm = CreateObject("ADODB.Stream")
- ADOStrm.Type = 2
- ADOStrm.Mode = 3
- ADOStrm.CharSet = s1
- ADOStrm.Open
- ADOStrm.LoadFromFile strFile
- s = ADOStrm.ReadText
- ADOStrm.Position = 0
- ADOStrm.CharSet = s2
- ADOStrm.WriteText s
- ADOStrm.SetEOS
- ADOStrm.SaveToFile newname, 2
- ADOStrm.Close
- end function
复制代码 这个是替换"<add key=""UseSecLCD"" value=""N"" 为"<add key=""UseSecLCD"" value=""Y"" 的
要是替换 <add key="SecondMonitorGridWidthSize" value="400" /> 中的400为某一个值的时候,该怎么办呢?是更改条件regEx.Pattern = "<add key=""UseSecLCD"" value=""N"" />"
吗?是的话是怎样更改???
原文http://zhidao.baidu.com/question/246540943.html |