2 Replies Latest reply on Jun 19, 2008 7:39 AM by Casey_Ilya

    Opening file on local drive for writing


      I'm trying to write to file, located in the root of my drive (in this example - c:\). But string
      var textFile = air.File.('file:///c:/MyTreeNotes.xml');
      throws exception:
      TypeError: Error #1034: Type Coercion failed: cannot convert "file:///c:/MyTreeNotes.xml" to flash.filesystem.File.

      I tried to write air.File('file://c:/MyTreeNotes.xml'), air.File('c:\\MyTreeNotes.xml'), but i have got nothing, but
      var textFile = air.File.desktopDirectory.resolvePath('MyTreeNotes.xml');
      works fine. May be there are some security restrictions, or i loose some small detail in file url?

      Thank you.

      Whole code:

      var xml = 'some valid XML'
      var textFile = air.File('file:///c:/MyTreeNotes.xml');
      var textStream = new air.FileStream();
      textStream.open(textFile, air.FileMode.WRITE);
      textStream.writeUTFBytes (BOM + '<?xml version="1.0" encoding="utf-8"?>' + xml);