日期:2014-05-16  浏览次数:20433 次

Javascript将表单的内容输出到一个txt,用哪些文件读写的函数
我是菜鸟,希望各位大师解答

------解决方案--------------------
fso就可以了吧

filestreamobject
------解决方案--------------------
Sub CreateFile()
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\testfile.txt", True)
' 写一行,并且带有新行字符。
tf.WriteLine("Testing 1, 2, 3.") 
'向文件写三个新行字符。
tf.WriteBlankLines(3) 
'写一行。
tf.Write ("This is a test.") 
tf.Close
End Sub
------解决方案--------------------
Sub CreateAfile
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
MyFile.WriteLine("这是一个测试。")
MyFile.Close
End Sub

Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", For Writing, True)
f.Write "嗨,你好!"
f.Close
End Sub
------解决方案--------------------
Sub CreateFile()
Dim fso, tf
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.CreateTextFile("c:\testfile.txt", True)
' 写一行,并且带有新行字符。
tf.WriteLine("Testing 1, 2, 3.") 
'向文件写三个新行字符。
tf.WriteBlankLines(3) 
'写一行。
tf.Write ("This is a test.") 
tf.Close
End Sub
这个示例示范了在 JScript 中如何使用这三个方法:

function CreateFile()
{
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
tf = fso.CreateTextFile("c:\\testfile.txt", true);
// 写一行,并且带有新行字符。
tf.WriteLine("Testing 1, 2, 3.") ;
// 向文件写三个新行字符。
tf.WriteBlankLines(3) ;
// 写一行。
tf.Write ("This is a test.");
tf.Close();
}
------解决方案--------------------
要注意的一点就是在js中\表示转义,如果要使用"\"要写两个"\\"