منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
لاستخراج صورة من مجمع Assembly - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : الأقسام التعليمية - المنتدى القديم (http://vb4arb.com/vb/forumdisplay.php?fid=90)
+--- قسم : مكتبة أكواد المنتدى (http://vb4arb.com/vb/forumdisplay.php?fid=111)
+---- قسم : مكتبة أكواد .net (http://vb4arb.com/vb/forumdisplay.php?fid=117)
+---- الموضوع : لاستخراج صورة من مجمع Assembly (/showthread.php?tid=6241)



لاستخراج صورة من مجمع Assembly - RaggiTech - 17-10-12

كاتب الموضوع : Boutemine Oualid

السلام عليكم و رحمة الله و بركاته

C#

كود :
/// *****************************************************
/// <summary>
/// Retrieves an embedded image.
/// </summary>
/// <param name="dir"> The directory. </param>
/// <param name="imgName"> The image's name. </param>
/// <param name="nspace"> The namespace. </param>
/// <returns> The image. </returns>
/// *****************************************************
public static Image GetAssemblyImage(string dir, string imgName, string nspace)
{
Assembly a = Assembly.GetExecutingAssembly(); // Current Assembly
string path = null;
// Top Directory or not ?
if (string.IsNullOrEmpty(dir)) path = string.Format("{0}.{1}", nspace, imgName);
else path = string.Format("{0}.{1}.{2}", nspace, dir, imgName);
// Retrieves the image
return Image.FromStream(a.GetManifestResourceStream(path));
}
VB.NET

كود :
' *****************************************************
' <summary>
' Retrieves an embedded image.
'</summary>
' <param name="dir"> The directory. </param>
' <param name="imgName"> The image's name. </param>
' <param name="nspace"> The namespace. </param>
'<returns> The image. </returns>
' *****************************************************
Public Shared Function GetAssemblyImage(ByVal dir As String, ByVal
imgName As String, ByVal nspace As String) As Image
Dim a As Assembly = Assembly.GetExecutingAssembly() ' Current Assembly
Dim path As String = Nothing
' Top Directory or not ?
If (String.IsNullOrEmpty(dir)) Then
path = String.Format("{0}.{1}", nspace, imgName)
Else
path = String.Format("{0}.{1}.{2}", nspace, dir, imgName)
End If
' Retrieves the image
Return Image.FromStream(a.GetManifestResourceStream(path))
End Function