最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

windows - How to access a sharednetwork folder using JavaScript? - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Apr 26, 2016 at 12:26 Kash asked Apr 25, 2016 at 10:04 KashKash 3411 gold badge5 silver badges15 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 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");

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

发布评论

评论列表(0)

  1. 暂无评论