4 Replies Latest reply on May 21, 2008 12:15 PM by Geidnert

    Read and Write files in Windows Vista

    Geidnert
      Im trying to make an AIR application that reads a file from the users document directory and then try to save it again when user have made the changes. It works fine on my mac, but when i try it on windows vista im getting the error code #3003 "File or directory doesnt exist", but it really DO exist. What am i doing wrong.. is there some security issues that i have missed? i have tryed with applicationStorageDirectory aswell and applicationDirectory, but nothing works. Very greatful for some advice on what im doing wrong.

      /Andreas

      _sellerFile = File.documentsDirectory ;
      _sellerFile = _sellerFile.resolvePath("faktura/data/seller.xml");

      var stream = new FileStream();
      try
      {
      stream.open(_sellerFile , FileMode.READ);
      var xml = XML(stream.readUTFBytes(stream.bytesAvailable));
      stream.close();

      seller = XMLParser.parseSeller(xml, this);
      displaySeller();
      }
      catch(e:Error)
      {
      errorMessage("Varning!", e.getStackTrace() + ", url: " + _sellerFile.url + ", path: " + _sellerFile.nativePath, "show");
      }
        • 1. Re: Read and Write files in Windows Vista
          Level 1
          I tried your example on Vista and it worked just fine for me. But I have my UAC turned off on vista.

          Can you make sure the error is actually happening in the lines that reads the file but not in the code that parses xml file? Try stepping through the code and find out which line is exactly throwing the error.

          -Jeesmon
          • 2. Re: Read and Write files in Windows Vista
            Geidnert Level 1
            Thx for the reply Jeesmon, i am pretty sure that its the open call, its the only one throwing this 3003 exception. And it is working on osx, the parsing. I might have to say also that its when the .air file is installed on vista as a program, and i am running it "for real" i am having the problem.

            I disable UAC also but i had the same problem after. grrrr....
            • 3. Re: Read and Write files in Windows Vista
              Level 1
              Are you seeing any issues when you open the file in a text editor? May be it is worth to take a look at permissions for the file for your vista user and the ownership of the file (properties -> Security). According to the documentation FileStream.open will throw error if there is no read permission on the file. Hope it's a physical file and not a link to any virtual store location. In the worst case, rename the existing file, manually create a text file and copy contents from original file to the new one and try. Good luck :)
              • 4. Re: Read and Write files in Windows Vista
                Geidnert Level 1
                Thx Jeesmon, your advices helped me in the right direction, it was some sort of permission error, everything looked fine when you browsed the files persiossions, so i tryed to recreate the file directly in vista, and that solved my problem.

                Thx alot for your help.

                /Andreas