' 写文件的函数(内容,路径,文件名) Public Sub FileWrite() Sub FileWrite(ByVal Str As String, ByVal myPath As String, ByVal myFileName As String) Dim path As String = HttpContext.Current.Server.MapPath(myPath) '路径 Dim temp As String = path & "" & myFileName '路径+文件名 ' 删除原文件,如果存在 If File.Exists(temp) Then File.Delete(temp) End If ' 建立新文件 Dim fs As FileStream = File.Create(temp) Dim info As Byte() = Encoding.GetEncoding("gb2312").GetBytes(Str) ' 把内容添加到文件中 fs.Write(info, 0, info.Length) fs.Close() 'Response.Write("<br>文件成功写入!")End Sub 转载于:https://www.cnblogs.com/pcsky/archive/2004/08/16/33884.html