views:

1977

answers:

5

This code does not seem to compile, I just need to write something to a small log text file (a new row to end of file).

<%@ Import Namespace="System.IO" %>

void Page_Load( object sender, EventArgs e ){

    FileSystem myFileSystem = new FileSystem();
    myFileSystem.WriteAllText(logFile, hash, false);
+2  A: 

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

Winston Smith
+1  A: 

I can't see any class called FileSystem in the System.IO namespace. Is this something new in .NET 4.0 which you're trying to use?

Note that the File class has a static method called WriteAllText. Is that what you meant?

EDIT: To append to a file instead, use File.AppendAllText.

Jon Skeet
Thanks, but WriteAllText does not seem to append to end of log file
Tom
Editing answer appropriately...
Jon Skeet
+2  A: 

FileSystem is in Microsoft.VisualBasic.File.IO. You'd have to reference that.

Although you probably don't really want FileSystem at all. You probably want System.IO.File

GeekyMonkey
A: 

This one seem to compile:

File myFileSystem = new File();
myFileSystem.AppendAllText(logFile, hash, false);
Tom
It shouldn't - File is a static class, and AppendAllText is a static method.
Jon Skeet
A: 

Without a doubt log4net! http://logging.apache.org/log4net/index.html

kenny