viva_unix

Hello!

I am writing an application for Smartphone and I am using an XML to store the data. XML file loaded fine and I am able to populate the DataSet with the data as good as validate the data with Schema. When I do some modification I want immidiately save the file. Looks like everything is fine. I can use the new rows that had been inserted into the dataset and no exception are thrown during WriteXML. When application restarted the data in the dataset is not updated from last modification. I have no idea why... :(

Code:

DataRow dr = this.ds.Tables[ "attr" ].NewRow();

dr[ "one" ] = strOne;

dr[ "two" ] = strTwo;

this.ds.Tables[ "attr" ].Rows.Add( dr );

////////////////// ... ////////////////////////

this.ds.AcceptChanges();

this.ds.WriteXml( "MyProj.data.xml" );

XML file is stored as an embedded resource.

Thank you!



Re: .NET Compact Framework DataSet.WriteXML does not want to save file... :(

Ilya Tumanov

Here¡¯s a hint: you can't update embedded resources, they are read only. But you'll find XML file called "MyProj.data.xml" in the root folder of your device. That's what that string means to DataSet.WriteXml() - a file name.






Re: .NET Compact Framework DataSet.WriteXML does not want to save file... :(

viva_unix

Do you know what is the way around this problem How to access an XML file if it is not embedded Where to find it on Smartphone What the properties for the XML file should I set in order to make it work

Thank you!





Re: .NET Compact Framework DataSet.WriteXML does not want to save file... :(

Ilya Tumanov

First of all, embedded resources are not really files. They are binary blobs inside your assembly.

In this case normal file is what you should use. Files are accessible the same was as on desktop - by file name. You've done that already by accident while trying to save resource and saving file instead.

Few things to remember: devices do not support drive letters, can't see your desktop hard drive and don't support relative paths, you have to always supply full path to each file.

To make VS deploy file for you set action to ¡°Content¡± and make sure to select something other than ¡°Do not copy¡± in ¡°Copy to Output Directory¡± property.






Re: .NET Compact Framework DataSet.WriteXML does not want to save file... :(

viva_unix

Thank you!

( ! ! ;) )