Windows 从特定文件夹获取特定文件
您好,我正在做一个Windows 8 Javascript应用程序,您知道如何从C:\Users\Me\Pictures\thifolder中获取文件名为example2.dat,我尝试使用Windows 从特定文件夹获取特定文件,windows,file,windows-runtime,directory,winjs,Windows,File,Windows Runtime,Directory,Winjs,您好,我正在做一个Windows 8 Javascript应用程序,您知道如何从C:\Users\Me\Pictures\thifolder中获取文件名为example2.dat,我尝试使用Windows.Storage.StorageFile.getFileFromPathAsync(“C:\Users\Me\Pictures\thisfolder”) 但它不起作用,因为我有另一个文件,如example1.dat、example3.dat example.jpg等 希望我把自己说清楚,提前谢谢
Windows.Storage.StorageFile.getFileFromPathAsync(“C:\Users\Me\Pictures\thisfolder”)代码>
但它不起作用,因为我有另一个文件,如example1.dat、example3.dat example.jpg等
希望我把自己说清楚,提前谢谢
这是到目前为止我的代码
function here() {
var getJsonStringAsync = function () {
return Windows.Storage.StorageFile.getFileFromPathAsync("C:\Users\Me\Pictures\thisfolder")
//Also tried this
//return Windows.Storage.KnownFolders.picturesLibrary.getFileAsync(u_u + "_" + u + "_" + ".dat")
.then(function (file) {
return Windows.Storage.FileIO.readTextAsync(file);
});
};
getJsonStringAsync().then(function (text) {
document.getElementById("line").innerHTML = text;
});
}
读取图片库中文件的正确方法如下:
(别忘了在应用程序清单中声明对picturesLibrary的访问权)
在JavaScript中,以下是如何播放音乐库中的“song.mp3”:
Html:
我也想得到一个文件夹里面的文字,希望你能帮忙
var getJsonStringAsync = function () {
var picturesLibrary = Windows.Storage.KnownFolders.picturesLibrary;
return picturesLibrary.getFolderAsync("thisfolder").then(function (folder){
return folder.getFileAsync("example2.dat").then(function (file) {
return Windows.Storage.FileIO.readTextAsync(file);
});
});
};
<audio id="player1">Your browser does not support audio </audio>
var ml = Windows.Storage.KnownFolders.musicLibrary;
ml.getFileAsync("song.mp3").then(function (file) {
// its a storage file, so create URL from it
var s = window.URL.createObjectURL(file);
player1.setAttribute("src", s);
player1.play();
//});
});