Thanks..That will work. However I have added try and catch function and modified the code as follows:
---------------------------------------------------------------------------------
- SPATH = "C:\\Complaints.txt";
-
DPATH = "C:\\Sammy\\";
-
-
XBOT_COPY(SPATH,DPATH);
-
-
//----Function to copy from one location to another
-
function XBOT_COPY(SRC_PATH,DST_PATH)
-
{
-
-
try {
-
-
var myObject, f;
-
myObject = new ActiveXObject("Scripting.FileSystemObject");
-
f = myObject.GetFile("C:\\Complaints.txt");
-
f.Copy("C:\\Sammy\\");
-
-
f.close();
-
myObject.close();
-
}
-
-
-
catch(err) {
-
var dt = new Date();
-
var FER = new ActiveXObject("Scripting.FileSystemObject");
-
var fFile = FER.OpenTextFile("C:\\Sammy\\Log\\xBotError.log",8, true,-1);
-
fFile.write(err+": "+err.description+" -- "+dt);
-
fFile.WriteBlankLines(1);
-
fFile.close();
-
fFile = null;
-
FER = null;
-
dt = null;
-
}
-
finally {
-
f = null;
-
myobject = null;
-
}
-
}
-
-------------------------------------------------------------------------
This is working and creating a logfile in the path specified - C:\\Sammy\\Log\\xBotError.log" , if there is any mismatch in filename or path name.
However if everything is fine also,it is working i.e copying complaints.txt file from "C:\\Complaints.txt" to "C:\\Sammy\\".
Still in logfile I am getting the log as [object Error]: Object doesn't support this property or method -- Thu Sep 25 14:43:45 UTC+0530 2008.
Is this log mandatory or there is any problem in my code?And how can I neglect this object error.
Can anyone explain?
Thanks.
Samita
-
-
function runCode(){
-
var myObject, f;
-
myObject = new ActiveXObject("Scripting.FileSystemObject");
-
f = myObject.GetFile("C:\\Complaints.txt");
-
if(!f){ return alert("File Not Found!"); }
-
f.Copy("C:\\Sammy\\");
-
}
-
-
runCode();
-
-
wrapping the code in a function allows more control over the code. and allows you to bail out without further execution.