我使用此代码保存到serverText
文件:
Dim mydocpath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Dim FILE_NAME As String = Server.MapPath("TextFile.txt")
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
objWriter.Write("XXX")
objWriter.Close()
MsgBox("Text written to file")
Else
MsgBox("File Does Not Exist")
End If
代码在global.asax文件的任何子文件中完美地工作(例如,Sub Session_Start
),但不在
Sub OnTimedEvent(ByVal source As Object, ByVal e As EventArgs)
也位于global.asax文件中。
为什么?