XMLファイルを保存しようとすると問題が発生しますXMLファイルをAssetsフォルダに保存し、ビルドアクションをAndroid資産に設定しますが、xml.Save( "Q317664.xml") ;パスへのアクセス「/Q317664.xmlは」denied.iが、これはXMLファイルの変更を保存できません
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.IO;
using System.Reflection;
using Android.Content.Res;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace App17
{
[Activity(Label = "App17", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
var xml = XDocument.Load(Assets.Open("Q317664.xml"));
var node = xml.Descendants("Book").FirstOrDefault(cd => cd.Attribute("Id").Value == "1");
node.SetAttributeValue("ISBN", "new");
xml.Save("Q317664.xml");
// Button button = FindViewById<Button>(Resource.Id.MyButton);
// button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
}
}
参照:http://stackoverflow.com/questions/10562904/is-asset-folder-read-only –
@Morrisonチャンその後、私はそのように私は、xmlファイルを保存する場所XMLファイルの属性を変更することができます –
xmlをファイルとしてアプリケーションのディレクトリに保存することができます。 – Sreeraj