zoukankan      html  css  js  c++  java
  • savetofile

    '*********************************************************
    ' 目的:    Save Text to File
    ' 输入:   
    ' 输入:   
    ' 返回:   
    '*********************************************************
    Function SaveToFile(strFullName,strContent,strCharset,bolRemoveBOM)

     On Error Resume Next

     Dim objStream

     Set objStream = Server.CreateObject("ADODB.Stream")
     With objStream
     .Type = adTypeText
     .Mode = adModeReadWrite
     .Open
     .Charset = strCharset
     .Position = objStream.Size
     .WriteText = strContent
     .SaveToFile strFullName,adSaveCreateOverWrite
     .Close
     End With
     Set objStream = Nothing

     If bolRemoveBOM Then
      If strContent<>"" And ZC_STATIC_TYPE="shtml" Then
       Call RemoveBOM(strFullName)
      End If
     End If

     Err.Clear

    End Function
    '*********************************************************

     


    '*********************************************************
    ' 目的:    Load Text form File
    ' 输入:   
    ' 输入:   
    ' 返回:   
    '*********************************************************
    Function LoadFromFile(strFullName,strCharset)

     On Error Resume Next

     Dim objStream

     Set objStream = Server.CreateObject("ADODB.Stream")
     With objStream
     .Type = adTypeText
     .Mode = adModeReadWrite
     .Open
     .Charset = strCharset
     .Position = objStream.Size
     .LoadFromFile strFullName
     LoadFromFile=.ReadText
     .Close
     End With
     Set objStream = Nothing

     Err.Clear

    End Function
    '*********************************************************


    '*********************************************************
    ' 目的:    Remove BOM from UTF-8
    '*********************************************************
    Function RemoveBOM(strFullName)

     On Error Resume Next

     Dim objStream
     Dim strContent

     Set objStream = Server.CreateObject("ADODB.Stream")
     With objStream
     .Type = adTypeBinary
     .Mode = adModeReadWrite
     .Open
     .Position = objStream.Size
     .LoadFromFile strFullName
     .Position = 3
     strContent=.Read
     .Close
     End With
     Set objStream = NoThing

     Set objStream = Server.CreateObject("ADODB.Stream")
     With objStream
     .Type = adTypeBinary
     .Mode = adModeReadWrite
     .Open
     .Position = objStream.Size
     .Write = strContent
     .SaveToFile strFullName,adSaveCreateOverWrite
     .Close
     End With
     Set objStream = Nothing

     Err.Clear

    End Function

  • 相关阅读:
    Silverlight 2 开发环境
    Silverlight: 通过LINQ 和Isolated Storage构建客户端数据库
    奥巴马就职委员会选择微软Silverlight技术
    Silverlight 和WPF的Composite Guidance(Prism V2)发布了
    分布式计算平台:Dryad
    Ironclad
    WCF安全指南
    WPF/Silverlight中的Command
    Silverlight 2 控件 SDK 源代码
    Mono 2.2 发布了
  • 原文地址:https://www.cnblogs.com/tatsuya/p/1212927.html
Copyright © 2011-2022 走看看