在文件夹中创建文本文件? [英] Create text file inside a folder?

查看:199
本文介绍了在文件夹中创建文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在phonegap IOS和Android文件夹中创建文本文件



How to create text file inside the folder in phonegap IOS and Android

function gotFS(fileSystem) {
                fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail);
            }

            function gotFileEntry(fileEntry) {
                fileEntry.createWriter(gotFileWriter, fail);
            }

            function gotFileWriter(writer) {
                writer.onwrite = function(evt) {
                    console.log("write success");
                };

                writer.write("some sample text");
                writer.abort();
                // contents of file now 'some different text'
            }


function onFileSystemSuccess(fileSystem) {
          console.log(fileSystem.name);
          var directoryEntry = fileSystem.root;
          
          directoryEntry.getDirectory($('.caseName_h').val(), {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail)

      }
      
      function onDirectorySuccess(parent) {
          console.log(parent);
      }

      function onDirectoryFail(error) {
          alert("Unable to create new directory: " + error.code);
      }

      function onFileSystemFail(evt) {
          console.log(evt.target.error.code);
      }

推荐答案

('。caseName_h')。val(),{create:true,exclusive:false}, onDirectorySuccess,onDirectoryFail)

}

函数onDirectorySuccess(parent){
console.log(parent);
}

函数onDirectoryFail(错误){
alert(无法创建新目录:+ error.code);
}

函数onFileSystemFail(evt){
console.log(evt.target.error.code);
}
('.caseName_h').val(), {create: true, exclusive: false}, onDirectorySuccess, onDirectoryFail) } function onDirectorySuccess(parent) { console.log(parent); } function onDirectoryFail(error) { alert("Unable to create new directory: " + error.code); } function onFileSystemFail(evt) { console.log(evt.target.error.code); }


参见如何到创建文本文件和插入数据到该文件上,机器人 [<一个href =http://stackoverflow.com/questions/8152125/how-to-create-text-file-and-insert-data-to-that-file-on-android\"target =_ blanktitle =New窗口> ^ ]



干杯,

Edo
See how-to-create-text-file-and-insert-data-to-that-file-on-android[^]

Cheers,
Edo


这篇关于在文件夹中创建文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆