سؤال

I'm trying to write/create a JSON file from a AIR app, I'm trying not so show a 'Save as' dialogue box.

Here's the code I'm using:

var fileDetails:Object = CreativeMakerJSX.getFileDetails();
var fileName:String = String(fileDetails.data.filename);
var path:String = String(fileDetails.data.path);
var f:File = File.userDirectory.resolvePath( path );
var stream:FileStream = new FileStream();
stream.open(f, FileMode.WRITE );
stream.writeUTFBytes( jsonToExport );
stream.close();

The problem I'm having is that I get a 'Error 3013. File or directory in use'. The directory/path is gathered from a Creative Suite Extension I'm building, this path is the same as the FLA being developed in CS that the Extension is being used with.

So I'm not sure if the problem is that there are already files in the directory I'm writing the JSON file to?

Do I need to add a timer in order to close the stream after a slight delay, giving some time to writing the file?

هل كانت مفيدة؟

المحلول 2

I re-wrote how the file was written, no longer running into this issue.

نصائح أخرى

Can you set up some trace() commands? I would need to know what the values of the String variables are, and the f.url.

Can you read from the file that you are trying to write to, or does nothing work?

Where is CreativeMakerJSX.getFileDetails() coming from? Is it giving you data about a file that is in use?

And from Googling around, this seems like it may be a bug. Try setting up a listener for when you are finished, if you have had the file open previously.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top