title: How to use resources and files in C#
body: <p>I have a program that consists of images. I want to put some images in a folder and show the content of that folder dynamically. the program should be portable. What should I do? I tried the following code but did not work:</p>
  
  <pre><code>String path = "Resources/Location.txt";
  String path2 = "/IconImagesForDummies/Icon";
  ObservableCollection&lt;IconImagesForDummies&gt; icons = new ObservableCollection&lt;IconImagesForDummies&gt;();
  String[] lines = null;
  if (File.Exists(path))
     lines = File.ReadAllLines(path, Encoding.Unicode);
  if (lines != null)
  {
     for (int i = 0; i &lt; lines.Length; ++i)
     {
          String str = path2 + @"/" + lines[i];
          if (File.Exists(str))
             icons.Add(new IconImagesForDummies() { Name = str });
     }
  }
  else
     throw new Exception("The Location.txt which stores the location of icons is missing");
  if (icons.Count == 0)
     throw new Exception("There is no icon image");
  </code></pre>
  
  <p>Location.txt contains the name of images. My problem is that the program could not find the Location.txt. I have inserted Location.txt in resources. I have to mention that I also used another approach. I made a new folder and instead of <code>String path = "Resources/Location.txt";</code>, I used the folder name but it did not work too. What should I do?</p>