Reputation: 341
I have a requirement to develop a tool to backup certain folders and files present in a shared drive (Windows 7) using Client-Side technologies (HTML5, CSS3 and JavaScript) only. Below is the JavaScript function to copy the file.
function copyFile() {
var myObject, f;
myObject = new ActiveXObject("Scripting.FileSystemObject");
f = myObject.GetFile("@\\Network_Name\Home$\User_Folder\Downloads\Folder_Name\Test.pdf");
if(!f)
{
return alert("File Not Found");
}
f.copy("@\\Network_Name\Home$\User_Folder\Downloads\Backup_Folder");
}
Since I'm using ActiveXObject
, the above code will work only in IE. But I'm getting the below error in the line @\\Network_Name\Home$\User_Folder\Downloads\Folder_Name\Test.pdf
. Please help me to properly access the network folder using JavaScript.
Upvotes: 1
Views: 10659
Reputation: 175768
The verbatim identifier (@
) is for C# not JavaScript, you need to escape your slashes:
.GetFile("\\\\Network_Name\\Home$\\User_Folder\\Downloads\\Folder_Name\\Test.pdf");
Upvotes: 3