Reputation: 3328
I have a problem to create exe file from assembly. In my project i have many file (jpg, txt) that i have added. When i build on my pc works fine, but if i use it in onother pc doesn't work(the path is always the same).
So i have setted recources as content and copy if newly (i have visual studio in italian language) and in the new release i have all resources, but neither works on other pc.
The path of resource is on my pc and i think that this is the problem
How i can build it?I would not provide the code. Thanks
I access to recources by directory scan:
String path = "../../../Reference";
directoryTxt = new DirectoryInfo(path + "\\txt").GetFiles()
.OrderBy(f => f.CreationTime)
.Select(f => f.FullName)
.ToArray();
directoryJpg = new DirectoryInfo(path).GetFiles()
.OrderBy(f => f.CreationTime)
.Select(f => f.FullName)
.ToArray();
directoryExercises = new DirectoryInfo("../../../ExercisesImages").GetFiles()
.Select(f => f.FullName)
.ToArray();
System.IO.StreamReader file = new System.IO.StreamReader("../../../MaskAngle/testExercise.txt");
Upvotes: 0
Views: 2481
Reputation: 2127
It is not enough to Copy to Output Directory your resources - this will result in copying the files into the build output folder on your development machine.
The simplest approach in you case would be to embed the files into the executable itself using Embedded Resource build action for each of them:
Then, you would access the files like described here.
Note As David pointed out in the comments, this way to deploy resources is sub-optimal. For large sets of files you should consider either bringing them using some installation package or, in case you don't need all of them on startup and you have a reliable connection from the target machine to some central server, providing them on demand remotely.
Upvotes: 1