samsung developer forum (you may not see unless you sign in...) 我在引用它。
case tvKey.KEY_RED:
alert('RED BUTTON!');
alert('CWID: '+curWidget.id);
try {
var fileSystemObj = new FileSystem();
var fileObj = fileSystemObj.openCommonFile(curWidget.id+'/testFile.data','w');
fileObj.writeLine('something to write.');
fileSystemObj.closeCommonFile(fileObj);
} catch (e) {
alert('Error: file handling: '+e);
}
break;
lead to error: alert() : Error: file handling: TypeError: 'null' is not an object (evaluating 'fileObj.writeLine') Reading cause same problem.
和解决方案在接受链接是:
I suppose that problem is that you have to create common dir (if does not exist) at first :
var fileObj = fileSystemObj.openCommonFile(filePath, 'w');
if(!fileObj){
var bValid = fileSystemObj.isValidCommonPath(curWidget.id);
if (!bValid) {
fileSystemObj.createCommonDir(curWidget.id);
}
}
fileObj = fileSystemObj.openCommonFile(filePath, 'w');
fileObj.writeLine('something to write.');
fileSystemObj.closeCommonFile(fileObj);
你的意思是[这个文件系统草案(http://www.w3.org/TR/file-system -API /)?在浏览器中几乎没有任何支持。三星电视运行什么浏览器?它确实支持FileSystem对象吗? – Rup 2012-03-15 16:07:54
@Rup支持根据开发人员指南http://freethetv2011.s3.amazonaws.com/App_Development_Guide_for_Samsung_Smart_TV%5BV1.20%5D%5B1%5D.pdf – antyrat 2012-03-15 16:10:47
@star尝试添加'try..catch'语句并提醒结果 – antyrat 2012-03-15 16:13:27