Domanda

I have an update utility in adobe air that needs to replace an existing file in application directory. but when I try to move file in application directory it throws IOError describing that file can not be deleted.

I did the following;

protected function onBtnTest(event:MouseEvent):void
{    
  try
  {
    service = new File(File.applicationDirectory.nativePath + File.separator +
      "assets" + File.separator + "oldFile.exe");        

    servic_ = new File(File.userDirectory.nativePath + File.separator + "newFile.exe");

    servic_.addEventListener(Event.COMPLETE, OnMoveComplete);
    servic_.addEventListener(IOErrorEvent.IO_ERROR, OnIOError);


    if(service.exists)
      servic_.moveToAsync(service, true);

  }
  catch(err:Error)
  {
    trace(err.message);
  }


}

private function OnMoveComplete(event:Event):void
{
  trace("Move Complete.");      
  trace("File Deleted.");
}

private function OnIOError(event:IOErrorEvent):void
{
  trace("OnIOError.");     
}

it always execute OnIOError function. but when I try to move same file to some other directory it works fine. How can I do this. Thanks

È stato utile?

Soluzione

Just one thing: You CAN'T write into the application directory, it's a flex security.

There is nothing you can do, sorry. Think about using another directory. Personally, I use the application storage directory instead.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top