[英]FileStream dosen´t work in actionscript 3 (Adobe Air)
I have a little problem here.. The code itself dosen´t get any errors, but it will not write to the .txt file... Hope someone can help me with this problem.我这里有一个小问题.. 代码本身没有任何错误,但它不会写入 .txt 文件...希望有人能帮助我解决这个问题。
Here is my code:这是我的代码:
test_btn.addEventListener(MouseEvent.CLICK, leggtil);
function leggtil(e:MouseEvent) {
var file:File = File.documentsDirectory.resolvePath("test.txt");
var fileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
var outputString:String = "test";
fileStream.writeUTFBytes(outputString);
fileStream.close();
}
I tested the code and it worked on my machine.我测试了代码,它在我的机器上工作。
I believe that the code is working for you, but you're not aware of where the file has been written.我相信代码对你有用,但你不知道文件是在哪里写的。 Check your documents folder.检查您的文档文件夹。 In Windows, this would be C:\\Users\\[your user name]\\Documents\\
.在 Windows 中,这将是C:\\Users\\[your user name]\\Documents\\
。 If you browse to that folder, you should see a file there named test.txt
.如果您浏览到该文件夹,您应该会在那里看到一个名为test.txt
的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.