GetManifestResourceStream 將使用如下格式編寫資源名稱:
<namespace>.<fileName>
在加載某些類型(比如 Bitmap 類)時,使用類型和文件名也是有用的,這樣可以通過提供構造函數避免由您自己打開流:
namespace ResourcesApp { public class Form1 : Form { public Form1() { ... // Get this type's assembly Assembly assem = this.GetType().Assembly; // Load the bitmap directly from the manifest resources this.BackgroundImage = new Bitmap(this.GetType(), "Azul.jpg"); } ... }}

Visual Studio .NET 中的清單資源
如果(大多數情況下)您使用 Visual Studio?NET 來開發和構建程序集,則用命令行嵌入清單資源的方法不可能非常吸引您。這種情況下,您可以將資源添加到 Windows 窗體項目中,該方法將把合適的命令行參數傳遞給編譯器。
要將資源添加到項目中,請在 Solution Explorer 中右鍵單擊項目,然后選擇 Add New Item,并選擇您想作為資源嵌入的文件。文件將復制到項目的目錄中,但仍然不會被嵌入。要使文件作為資源嵌入,請右鍵單擊文件,并選擇 Properties,然后將 Build Action 從 Content(默認)更改為 Embedded Resource,如圖 3 所示。

圖 3. 將文件的 Build Action 設置為 Embedded Resource
這種嵌入資源的方法會使 Visual Studio .NET 為您創建一個備用資源名,其組成類似這樣:
<defaultNamespace>.<folderName>.<fileName>
資源名稱的默認命名空間部分是項目本身的默認命名空間,它是通過 Solution Explorer->(右鍵單擊)->Properties->Common Properties->General->Default Namespace 來設置的。由于這是在生成新類時,新類得到的相同命名空間,所以這就使通過使用類型和部分資源名稱來加載資源變得很方便。如果文件碰巧位于項目的子文件夾中,就需要在文件夾名稱中包括子文件夾,并用點替換反斜杠。例如,一個名為 Azul.jpg 的位圖位于項目根下面的 foo\bar 文件夾中,要加載它就需要這樣做:
// If this code called within the ResourcesApp.Form1 class,// and the file is \foo\bar\Azul.jpg,// will load ResourcesApp.foo.bar.Azul.jpgthis.BackgroundImage = new Bitmap(this.GetType(), "foo.bar.Azul.jpg");