Keep in touch

you can keep in touch with my all blogs and sites by install this Toolbar...
http://rworldtoolbar.ourtoolbar.com/

Saturday, March 6, 2010

Write To A File on Server in ASP.NET

Public Shared Function SaveTextToFile(ByVal strData As String, ByVal fname As String) As Boolean
Try
Dim fs As New FileStream(fname, FileMode.Create, FileAccess.Write)
Dim s As New StreamWriter(fs)
s.BaseStream.Seek(0, SeekOrigin.End)
s.WriteLine(strData)
s.Close()
Return True
Catch ex As Exception
' your exception handler here
End Try
Return False
End Function

No comments: