I have an XML which is inside the application directory I need to modify that XML file.First i load that XML with URLLoder using the below codes and then modify the XML and when i try to write the XML file in same location with the same name it is not working.If i change the file name to something else then it is working fine.So my problem is that i want to modify the XML file and save it in the same location with the same name.How can i achieve this?
private var ldr:URLLoader;
private function changeAppID():void
{
var FolderPath = File.applicationDirectory.nativePath+"\\assets"
var tempFile:File = File.userDirectory.resolvePath(FolderPath);
if(tempFile.exists)
{
ldr = new URLLoader();
ldr.addEventListener(Event.COMPLETE, onLoad);
ldr.load(new URLRequest(FolderPath + "\\data\\application.xml"));
}
else
{
trace("Assets Folder Does Not Exists !");
}
}
protected function onLoad(event:Event):void
{
var bytearray:ByteArray = new ByteArray();
var loadedXml:XML = new XML((event.target).data);
loadedXml.children()[0] = "Riaxe"+getCurrentTime();
bytearray = getXMLToByteArray( loadedXml );
var path:String = File.applicationDirectory.nativePath + "\\assets\\data\\application.xml";
var file:File = new File(path);
var fileStream:FileStream = new FileStream();
fileStream.open( file, FileMode.WRITE );
fileStream.writeBytes( bytearray , 0 , bytearray.length );
fileStream.close();
}