cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James M Earle III" <jmea...@mindspring.com>
Subject Can't get cordova 2.2 File api to work.
Date Fri, 16 Nov 2012 05:52:51 GMT
Hey,

 

I am trying to open and write/read a file on WinPhone 7.10.xxx or 7.5 using
File api.

 

Here is the app in index.html and error following.

 

Says it can't load content which makes me think html is malformed but can't
find any.

 

Can anybody tell me what is wrong or try it out?

 

 

Index.html

<!DOCTYPE html>

<html>

<head>

    <title>FileReader Example</title>

    <script type="text/javascript" charset="utf-8"
src="cordova-2.2.0.js"></script>

    <script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load

    function onLoad() {

        document.addEventListener("deviceready", onDeviceReady, false);

    }

    // Cordova is ready        

    function onDeviceReady() {

        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS,
fail);

    }

    function gotFS(fileSystem) {

        fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);

    }

    function gotFileEntry(fileEntry) {

        fileEntry.file(gotFile, fail);

    }

    function gotFile(file) {

        readDataUrl(file);

        readAsText(file);

    }

    function readDataUrl(file) {

        var reader = new FileReader();

        reader.onloadend = function (evt) {

            console.log("Read as data URL");

            console.log(evt.target.result);

        };

        reader.readAsDataURL(file);

    }

    function readAsText(file) {

        var reader = new FileReader();

        reader.onloadend = function (evt) {

            console.log("Read as text");

            console.log(evt.target.result);

        };

        reader.readAsText(file);

    }

    function fail(evt) {

        console.log(evt.target.error.code);

    }    

    </script>

</head>

<body>

    <h1>

        Example</h1>

    <p>

        Read File</p>

</body>

</html>

 

 

And console output from running on emulator in Win7 and VS2010 Pro with
phone sdks

 

'UI Task' (Managed): Loaded 'mscorlib.dll'

'UI Task' (Managed): Loaded 'System.Windows.RuntimeHost.dll'

'UI Task' (Managed): Loaded 'System.dll'

'UI Task' (Managed): Loaded 'System.Windows.dll'

'UI Task' (Managed): Loaded 'System.Net.dll'

'UI Task' (Managed): Loaded 'System.Core.dll'

'UI Task' (Managed): Loaded 'System.Xml.dll'

'UI Task' (Managed): Loaded
'\Applications\Install\70C414C4-F9F3-4CCE-800F-4219EC2A8C2B\Install\CordovaA
ppProj_2.2.01.dll', Symbols loaded.

'UI Task' (Managed): Loaded 'Microsoft.Phone.dll'

'UI Task' (Managed): Loaded 'Microsoft.Phone.Interop.dll'

'UI Task' (Managed): Loaded
'\Applications\Install\70C414C4-F9F3-4CCE-800F-4219EC2A8C2B\Install\WP7Cordo
vaClassLib.dll', Symbols loaded.

'UI Task' (Managed): Loaded 'System.Xml.Linq.dll'

'UI Task' (Managed): Loaded 'System.Runtime.Serialization.dll'

'UI Task' (Managed): Loaded 'System.SR.dll'

A first chance exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll

A first chance exception of type
'System.IO.IsolatedStorage.IsolatedStorageException' occurred in
mscorlib.dll

Updating IsolatedStorage for APP:DeviceID ::
7a5ef5bd-09b6-4f09-b5fe-6786e7188b5a

INFO: Creating Directory :: /app/www

INFO: Writing data for /app/www\cordova-2.2.0.js and length = 205469

INFO: Creating Directory :: /app/www\img

INFO: Writing data for /app/www\img\logo.png and length = 21814

INFO: Creating Directory :: /app/www\js

INFO: Writing data for /app/www\js\index.js and length = 1914

INFO: Writing data for /app/www\ProjHelp.txt and length = 1947

INFO: Creating Directory :: /app/www\css

INFO: Writing data for /app/www\css\index.css and length = 3719

INFO: Writing data for /app/www\index.html and length = 1532

GapBrowser_Navigated :: /app/www/index.html

'UI Task' (Managed): Loaded 'System.ServiceModel.Web.dll'

'UI Task' (Managed): Loaded 'System.ServiceModel.dll'

The thread '<No Name>' (0xe6900fe) has exited with code 0 (0x0).

Error:"Unable to get value of the property 'content': object is null or
undefined file:x-wmapp1:/app/www/index.html Line:1"

The thread '<No Name>' (0xe7300da) has exited with code 0 (0x0).

A first chance exception of type 'System.SystemException' occurred in
Microsoft.Phone.Interop.dll

The thread '<No Name>' (0xf63010e) has exited with code 0 (0x0).

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message