Can anybody give some sample code to read and write a file using JavaScript?
If you are using JScript (Microsoft's Javascript) to do local scripting using WSH (NOT in a browser!) you can use Scripting.FileSystemObject
to access the file system.
I think you can access that same object in IE if you turn a lot of security settings off, but that would be a very, very bad idea.
MSDN here