1 Reply Latest reply on Aug 26, 2008 6:23 AM by kiwi_ziesch

    rename a chosen file

    kiwi_ziesch Level 1
      hey, I´ve some probs with renaming files...here´s how it goes:

      I browse for a file and want to rename it.
      the new name is already generated.
      and now I just want to replace the old name of the file with my new generated one and "save" this to the filesystem - means overwrite the old filename.

      in the documentation I´ve found this code:
      var original = air.File.documentsDirectory.resolvePath("AIR Test/test.txt");
      var newFile = air.File.documentsDirectory.resolvePath("AIR Test/copy.txt");
      original.copyTo(newFile, true);

      but I don´t know how to point on the directory of the file...because I browse to it. in the docs the directory is already set...

      I´ve tried to replace "air.File.documentsDirectory.resolvePath("AIR Test/test.txt"); " with the source (means url) of my file and "air.File.documentsDirectory.resolvePath("AIR Test/copy.txt"); " with the url I´ve put together out of the parent path of the chosen directory, my new filename and its extension. but I got this error message: "TypeError: Value undefined (result of expression original.copyTo) is not object."

      maybe it sounds confusing but I hope some of you guys can help me out.
      thanks so far.