2014-04-15 74 views
0

我在DataGridnView中读取XML文件但是在XML文件中有一个图像并且在Datagrindview中只读取它作为路径。从XML文件中读取图像

private void button1_Click(object sender, EventArgs e) 
{ 
    DataSet A = new DataSet(); 
    A.ReadXml("C:/TrainedLabels.xml"); 
    dataGridView1.DataSource = A.Tables[0]; 
} 

这里XML文件:

<?xml version="1.0" encoding="utf-8"?> 
<Faces_For_Training> 
    <FACE> 
    <NAME>john</NAME> 
    <Age>25</Age> 
    <informations>Student in MS uni</informations> 
    <FILE>face_john 25Student in MSA university_905807542.jpg</FILE> 
    </FACE> 
    <FACE> 
    <NAME>Alia</NAME> 
    <Age>28</Age> 
    <informations>engineer</informations> 
    <FILE>face_Alia 28engineer_390671740.jpg</FILE> 
    </FACE> 
</Faces_For_Training> 

它使图像的像face_Alia 28engineer_390671740.jpgFILEcolumn路径。 任何建议如何我可以读取图像。谢谢 。

回答

0

将XML读入DataSetA后,可以通过A.Tables[0].Columns["FILE"]访问文件名。然后您可以使用System.Drawing.Image.FromFile加载它。

+0

谢谢你对Response的想法,我认为使用xml作为数据库对我来说是个坏主意。呵呵。所以我会通过vs数据库,并为我的脸识别。再一次非常感谢你 :) 。 – user3098164