CreateTextFile方法是建立新的TextStream 对象,就是说它创建了新的file对象,所以覆盖是一定的。
tf = fso.CreateTextFile("c:\\test1.txt",true); //覆盖原来已经存在的同名文件
tf = fso.CreateTextFile("c:\\test1.txt",false); //不覆盖原来已经存在的同名文件
应该是:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<SCRIPT language=JavaScript>
function CreateFile()
{
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
tf = fso.OpenTextFile("c:\\test1.txt",8,true); // 写一行,并且带有新行字符。
tf.WriteLine("Testing\n") ;
// 向文件写三个新行字符。
tf.WriteBlankLines(3) ; tf.Write ("This is a test.\n");
tf.Close();
} </SCRIPT>
</head>
<body>
<a href="#" onclick="CreateFile()">aaa
</a>
</body>
</html>
tf = fso.CreateTextFile("c:\\test1.txt",true); //覆盖原来已经存在的同名文件
tf = fso.CreateTextFile("c:\\test1.txt",false); //不覆盖原来已经存在的同名文件
应该是:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<SCRIPT language=JavaScript>
function CreateFile()
{
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
tf = fso.OpenTextFile("c:\\test1.txt",8,true); // 写一行,并且带有新行字符。
tf.WriteLine("Testing\n") ;
// 向文件写三个新行字符。
tf.WriteBlankLines(3) ; tf.Write ("This is a test.\n");
tf.Close();
} </SCRIPT>
</head>
<body>
<a href="#" onclick="CreateFile()">aaa
</a>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货