How to write something to a .txt file from an .aspx file (C #)
This code doesn't seem to compile, I just need to write something to a small text log file (newline to end of file).
<%@ Import Namespace="System.IO" %>
void Page_Load( object sender, EventArgs e ){
FileSystem myFileSystem = new FileSystem();
myFileSystem.WriteAllText(logFile, hash, false);
source to share
I don't see any class called FileSystem in the namespaceSystem.IO
. Is this something new in .NET 4.0 that you are trying to use?
Note that the class File
has a static method called WriteAllText
. Is this what you mean?
EDIT: Add to the file instead File.AppendAllText
.
source to share
FileSystem is a class from the VisualBasic namespace:
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.filesystem.aspx
Have a look at the FileStream class in C #:
http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx
source to share