- Set fso = CreateObject("Scripting.FileSystemObject")
- inifile = "F:\aaa\bbb\aaa.ini"
- folder = left(inifile,InStrRev(inifile,"\"))
-
- If right(folder,1) <> "\" Then folder=folder&"\"
- arr = Split(folder, "\")
- subfolder = arr(0)
- For i = 1 To UBound(arr)-1
- subfolder = subfolder & "\" & arr(i)
- If Not fso.FolderExists(subfolder) Then fso.CreateFolder(subfolder)
- Next
-
- If Not fso.FileExists(inifile) Then
- fso.CreateTextFile(inifile, 2).Write("[abcd]"&vbCrLf&"abcd=xyz")
- Else
- Set f = fso.OpenTextFile(inifile, 1)
- text = f.ReadAll()
- f.Close()
- If InStr(text,"[abcd]")< 1 Then
- fso.OpenTextFile(inifile, 8).Write("[abcd]"&vbCrLf&"abcd=xyz")
- End If
- End If
复制代码
|