Using ActiveX - FileSystemObject I would like to: - Open an existing file - Read the first 28 bytes from it and store them in var str1 - Read the next 1000 bytes from it and store them in var str2 - Create a new file with this content: str1 + text_param + str2
This is my Javascript code:
function exportFile(text)
{
var fso, f2;
fso = new ActiveXObject("Scripting.FileSystemObject");
f2 = fso.OpenTextFile("C:\\default.js",1)
var str1=f2.Read(28);
f2.Skip(28);
var str2=f2.Read(1000);
f2.Close;
f2.CreateTextFile("C:\\new.js",true);
f2.Write(str1+text+str2);
}
But it doesn't work. I get this error message (in Spanish), referin开发者_开发百科g to the line of the f2.Close. It says, literally, "The object does not accept this property of method". I tried removing this line and the error goes to the next line (CreateTextFile).
Could you help me? THANKS
Detalles de error de página web
Agente de usuario: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; InfoPath.2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)
Fecha: Sun, 7 Nov 2010 11:37:07 UTC
Mensaje: El objeto no acepta esta propiedad o método
Línea: 69
Carácter: 5
Código: 0
URI: file:///C:/freeEdition.html
You're missing the ()
after f2.close
.
精彩评论