⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readini.asp

📁 50个完整的ASP小例子
💻 ASP
字号:
<%
class IniFile
    private mFileName
    private mDictionary
    
    private sub class_initialize()
        set mDictionary=Server.CreateObject("Scripting.Dictionary")
    end sub
    
    public property Let FileName(vFileName)
        dim mFileSys 
        dim mIniFile
        dim mSection
        dim mKeyName
        dim mValue
        dim mString
        dim mStart
        mFileName=vFileName
        set mFileSys=server.CreateObject("Scripting.FileSystemObject")
        set mIniFile=mfilesys.OpenTextFile(mFileName,1)
        do while not mIniFile.AtEndOfStream
            mString=mIniFile.ReadLine
            if mString<>"" then
                if left(mString,1)<>";" then
                    if left(mString,1)="[" then
                        mSection=mid(mString,2,len(mstring)-2)
                    else
                        mStart=instr(mstring,"=")
                        mKeyName=left(mstring,mStart-1)
                        mDictionary.Add lcase(mSection) & "_" & lcase(mKeyName),mid(mString,mStart+1)
                    end if
                end if
            end if
        loop
        mIniFile.Close
        Set mFileSys=nothing
        set mIniFile=nothing
    end property
    
    Public Function GetIniValue(byval vSection,byval vKeyName)
        on error resume next
        GetIniValue=mDictionary(lcase(vSection) & "_" & lcase(vKeyName))
    End Function
    
End Class
%>
<Html>
<Title>读取INI文件</Title>
<Body>
<h2>读取INI文件</h2>
<%
dim mINI 
set mINI=new inifile
mINI.FileName = "d:\1.ini"
Response.Write "[Company]" & "<br>Phone="
Response.Write  mINI.GetIniValue("Company","phone")

%>
</Body>
</Html>    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -