# browseForSave error in air/as3

**URL:** <https://forum.kirupa.com/t/browseforsave-error-in-air-as3/268304>\
**Category:** flash\
**Created:** [August 12, 2008, 1:25pm UTC](https://forum.kirupa.com/t/browseforsave-error-in-air-as3/268304 "2008-08-12T13:25:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![badFortune](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@badFortune](https://forum.kirupa.com/u/badFortune)\
**Post date:** [August 12, 2008, 1:25pm UTC](https://forum.kirupa.com/t/browseforsave-error-in-air-as3/268304/1 "2008-08-12T13:25:38Z")

</div>

Hi,

I’m getting the following error;

SecurityError: fileWriteResource  
at runtime::SecurityManager$/checkPrivilegeForCaller()  
at flash.filesystem::FileStream/open()  
at anno::XmlParserClass/saveData()

When I use the following code;

```auto
	 
//browse code i'm having trouble with starts here at the end of one of my functions.

       var appDir:File = File.applicationDirectory;
			try
			{
			    appDir.browseForSave("Save As");
		    	appDir.addEventListener(Event.SELECT, saveData);
			}
			catch (error:Error)
			{
			    trace("Failed:", error.message);
			}

		}; // end function saveXML
			
			
		function saveData(myE:Event):void 
		{
			var outputString:String = new String(ttFrame_xml.toString());
			var newFile:File = myE.target as File;
				
			if (!newFile.exists)
			{
				var stream:FileStream = new FileStream();
				stream.open(newFile, FileMode.WRITE);
				stream.writeUTFBytes( outputString );
				stream.close();
			}
		};

```

This is taken almost straight from the adobe pages (AIR / flash.filesystem / browseforSave )

I cannot see where the problem is. If anyone else can I’d appreciate it.

Thanks
