// create a file writer object
function CreateFileWriter()
{
// request the file system object
window.requestFileSystem( LocalFileSystem.PERSISTENT, 0, OnFileSystemSuccess,fail);
}
function OnFileSystemSuccess( pFileSystemObj )
{
console.log( pFileSystemObj.name );
console.log( pFileSystemObj.root.name );
pFileSystemObj.root.getFile( "file_name.txt", {create: true, exclusive: false}, OnFileGetSuccess, fail);
}
function OnFileGetSuccess( pFileEntryObj )
{
pFileEntryObj.createWriter( function(pWriterObj){
gWriterObj = pWriterObj;
}, fail );
}
function fail(evt)
{
console.log(evt.target.error.code);
}
Run Code Online (Sandbox Code Playgroud)
这里创建文件编写器方法提供了文件系统的句柄.在success函数中,我们得到名为'file_name.txt'的文件,如果存在则打开,否则创建它.
| 归档时间: |
|
| 查看次数: |
3155 次 |
| 最近记录: |