As described above, the for and foreach blocks of code below are
functionally equivalent.
[C#]
XImageLoadOptions loadOptions = new XImageLoadOptions();
loadOptions.ReadIPTC = true;
XImage image = XImage.FromFile(Server.MapPath("rez/myimg.jpg"), loadOptions);
if (image.IPTC != null) {
foreach (IPTCRecord iptc in image.IPTC) {
Response.Write(iptc.Text + "<br>");
}
for (int i = 1; i <= image.IPTC.Count; i++) {
Response.Write(image.IPTC[i - 1].Text + "<br>");
}
}
[Visual Basic]
Dim loadOptions As New XImageLoadOptions()
loadOptions.ReadIPTC = True
Dim image As XImage = XImage.FromFile(Server.MapPath("rez/myimg.jpg"), loadOptions)
If image.IPTC IsNot Nothing Then
For Each iptc As IPTCRecord In image.IPTC
Response.Write(iptc.Text & "<br>")
Next
For i As Integer = 1 To image.IPTC.Count
Response.Write(image.IPTC(i - 1).Text & "<br>")
Next
End If
|