www.gusucode.com > CC校友录贴吧 CCBar源码程序asp编程 > inc/inc_inifile_func.asp
<% Set InIfileDictionary = CreateObject("Scripting.Dictionary") Sub InIfileLoad(ByVal FilSpc) InIfileDictionary.RemoveAll FilSpc = FilSpc If left(FilSpc, 1) = "p" Then 'Physical path PhyPth = mid(FilSpc, instr(FilSpc, "=") + 1) Else 'Virtual path PhyPth = Server.MapPath(mid(FilSpc, instr(FilSpc, "=") + 1)) End If Set FilSys = CreateObject("Scripting.FileSystemObject") Set InIfil = FilSys.OpenTextFile(PhyPth, 1) Do While Not InIfil.AtEnDofStream StrBuf = InIfil.ReadLine If StrBuf <> "" Then 'There is data on this line If left(StrBuf, 1) <> ";" Then 'It's Not a comment If left(StrBuf, 1) = "[" Then 'It's a section header HdrBuf = mid(StrBuf, 2, len(StrBuf) - 2) Else 'It's a value StrPtr = instr(StrBuf, "=") AltBuf = HdrBuf & "|" & left(StrBuf, StrPtr - 1) Do While InIfileDictionary.Exists(AltBuf) AltBuf = AltBuf & "_" Loop InIfileDictionary.Add AltBuf, mid(StrBuf, StrPtr + 1) End If End If End If Loop InIfil.Close Set InIfil = Nothing Set FilSys = Nothing End Sub Function InIfileValue(ByVal ValSpc) Dim Ifarray Dim i StrPtr = instr(ValSpc, "|") ValSpc = ValSpc If StrPtr = 0 Then 'They want the whole section StrBuf = "" StrPtr = len(ValSpc) + 1 ValSpc = ValSpc + "|" Ifarray = InIfileDictionary.Keys For i = 0 to InIfileDictionary.Count - 1 If left(Ifarray(i), StrPtr) = ValSpc Then 'This is from the section If StrBuf <> "" Then StrBuf = StrBuf & "~" End If StrBuf = StrBuf & Ifarray(i) & "=" & InIfileDictionary(Ifarray(i)) End If Next Else 'They want a specIfic value StrBuf = InIfileDictionary(ValSpc) End If InIfileValue = StrBuf End Function %>