- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml;
-
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
-
- public Form1()
- {
- InitializeComponent();
- }
-
- /**
- * ファイルを開く
- */
- private void button1_Click(object sender, EventArgs e)
- {
- OpenFileDialog ofd = new OpenFileDialog();
- // XMLのみ指定
- ofd.Filter = "XMLファイル(*.xml)|*.xml";
- // ダイアログ表示
- DialogResult dialogResult = ofd.ShowDialog();
-
- // 開くが押された場合
- if (dialogResult == DialogResult.OK)
- {
- textBox1.Text = ofd.FileName;
- }
- }
-
- /**
- * XML整形を実行
- */
- private void button2_Click(object sender, EventArgs e)
- {
- if (!"".Equals(this.textBox1.Text))
- {
- String file = textBox1.Text;
- XmlDocument xml = new XmlDocument();
- xml.Load(file);
- // 上書き
- xml.Save(file);
-
- MessageBox.Show("上書き保存しました。", "メッセージ", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
- }
- }
-
- }
- }
|