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:
String path = "Resources/Location.txt";
String path2 = "/IconImagesForDummies/Icon";
ObservableCollection<IconImagesForDummies> icons = new ObservableCollection<IconImagesForDummies>();
String[] lines = null;
if (File.Exists(path))
lines = File.ReadAllLines(path, Encoding.Unicode);
if (lines != null)
{
for (int i = 0; i < 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");
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 String path = "Resources/Location.txt";
, I used the folder name but it did not work too. What should I do?