Я использую xmlwriter в C# для создания xml-файла, который содержит записи для членов клуба. Я хочу сохранить с записью каждого участника ссылку на местоположение идентификационной фотографии людей, которая будет храниться в папке.Ссылка на размещение изображения в файле xml
private void button1_Click(object sender, EventArgs e)
{
string documentPath = @"D:\Book6.xml";
XmlDocument myxDoc = new XmlDocument();
myxDoc.Load(documentPath);
//Member Node creation
XmlNode member = myxDoc.CreateElement("Member");
//XmlNode information = myxDoc.CreateElement("Information");
XmlNode name = myxDoc.CreateElement("Name");
name.InnerText = txtName.Text;
member.AppendChild(name);
//
XmlNode dateofbirth = myxDoc.CreateElement("DateofBirth");
dateofbirth.InnerText = txtDOB.Text;
member.AppendChild(dateofbirth);
//
XmlNode idnumber = myxDoc.CreateElement("IdNumber");
idnumber.InnerText = txtID.Text;
member.AppendChild(idnumber);
//
XmlNode address = myxDoc.CreateElement("Address");
address.InnerText = txtAddress1.Text;
member.AppendChild(address);
//
XmlNode contactnumber = myxDoc.CreateElement("ContactNumber");
contactnumber.InnerText = txtCellnumber.Text;
member.AppendChild(contactnumber);
//
XmlNode email = myxDoc.CreateElement("Email");
email.InnerText = txtEmail.Text;
member.AppendChild(email);
//
XmlNode designation = myxDoc.CreateElement("Designation");
designation.InnerText = txtDesignation.Text;
member.AppendChild(designation);
//
XmlNode branch = myxDoc.CreateElement("Branch");
branch.InnerText = txtBranch.Text;
member.AppendChild(branch);
//
XmlNode province = myxDoc.CreateElement("Province");
province.InnerText = txtProvince.Text;
member.AppendChild(province);
//
XmlNode district = myxDoc.CreateElement("District");
district.InnerText = txtDistrict.Text;
member.AppendChild(district);
//
XmlNode constituency = myxDoc.CreateElement("Constituency");
constituency.InnerText = txtConstituency.Text;
member.AppendChild(constituency);
//
XmlNode formnumber = myxDoc.CreateElement("FormNumber");
formnumber.InnerText = txtFormNum.Text;
member.AppendChild(formnumber);
//
XmlNode subscription = myxDoc.CreateElement("Subscription");
subscription.InnerText = txtSubscripton.Text;
member.AppendChild(subscription);
//
XmlNode period = myxDoc.CreateElement("Period");
period.InnerText = txtPeriod.Text;
member.AppendChild(period);
//
XmlNode image = myxDoc.CreateElement("Image");
image.InnerText = txtName.Text;//imageLocation; //imagePhoto.ToString();
member.AppendChild(image);
//member.AppendChild(information);
myxDoc.DocumentElement.AppendChild(member);
myxDoc.Save(documentPath);
txtName.Text = String.Empty;
txtDOB.Text = String.Empty;
txtID.Text = String.Empty;
txtAddress1.Text = String.Empty;
txtAddress2.Text = String.Empty;
txtAddress3.Text = String.Empty;
txtCellnumber.Text = String.Empty;
txtEmail.Text = String.Empty;
txtDesignation.Text = String.Empty;
txtBranch.Text = String.Empty;
txtProvince.Text = String.Empty;
txtDistrict.Text = String.Empty;
txtConstituency.Text = String.Empty;
txtFormNum.Text = String.Empty;
txtSubscripton.Text = String.Empty;
txtPeriod.Text = String.Empty;
txtWard.Text = String.Empty;
}
private void btnPhoto_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
//filters
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
imagePhoto.Image = new Bitmap(open.FileName);
imagePhoto.SizeMode = PictureBoxSizeMode.StretchImage;
imageLocation = open.FileName;
}
}
}
}
У вас есть конкретная проблема или просто рассказываете нам, что вы делаете? – leppie
извините, да, проблема в том, как я могу сделать расположение файла открытым как ссылка, когда я открываю xml-файл в excel – ngoni
@leppie да мне нужна помощь в том, как сделать его ссылкой, чтобы при открытии xml в excel it это активная ссылка, которая работает – ngoni