user2448122 user2448122 - 1 month ago 5
C# Question

dot instead of slash in c# file path

I am making my first steps with C#. Taken over a project, and wondering why does the following code work:

Stream myStream = myAssembly.GetManifestResourceStream("ConfigTool.resources.bg.bmp");


I am wondering about the dots in the file path. Why is this okay? I would expect to see something like

Stream myStream = myAssembly.GetManifestResourceStream("ConfigTool\\resources\\bg.bmp");


Which is not working. So I am puzzled.
The directory structure for the record is:

\ConfigTool\reources\bg.bmp
\ConfigTool\bin\Debug\myApplication.exe

Answer

the file structure at your disk is the same to package structure in project/application (it defines this structure). and the app gets resources from packages (in apps logic) not from files. this is why you use dot notification not slashes.

Comments