1

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.

Snapshot of Error

2 Answers 2

3

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");
Sign up to request clarification or add additional context in comments.

Comments

0

Try to use Ajax request method type "GET" for this purpose.

3 Comments

Hi Vatsal, can you please provide me a code sample to access network drive using $.get() method.
Ajax communicates with a web server not a network file system.
$.get({ url:@\\Network_Name\Home$\User_Folder\Downloads\Folder_Name\Test.pdf , data: DataToBeInserted,//optional success: function({ }), dataType: text });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.