منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : لاستخراج صورة من مجمع Assembly
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
كاتب الموضوع : 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