繁体   English   中英

如何使用javascript访问用户本地资料?

[英]How to access user local profile using javascript?

我正在寻找访问用户本地配置文件,例如C:\\Users\\username\\AppData\\Local 到目前为止,还不错,但是我想听听专家的信息,我该如何访问用户本地资料?

更新资料

如果我尝试使用以下代码段在C:\\Users\\username\\Desktop创建它,但是当我尝试使用\\\\AppData\\\\Local\\\\ABC.txt它提示Path not found

function createFile(){
    var fileObj = new ActiveXObject("Scripting.FileSystemObject");
    var fileName = "ABC.txt";

    if(fileObj.FileExists(fileName)){
        //empty file
        var emptyFile = fileObj.OpenTextFile(fileName, 2, false);
        emptyFile.close();
        //write to file
        var openFile = fileObj.OpenTextFile(fileName, 2, false);
        openFile.WriteLine("Created from JS");
        openFile.close();       
    }
    else{
        //create new file
        var newfile = fileObj.CreateTextFile(fileName,false);
        //write to file
        newfile.WriteLine("Created from JS");
        newfile.close();
    }
}

AppData包含默认情况下其他用户无法访问的数据文件夹。

您需要更改用户访问AppData的权限。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM