C
C#3mo ago
Gooburr

issue with paths and stuff idk

im trying to figure out how to make a game in c# and basically I want to use an image on a windows forms app but the only way to point to it is via the path (ie c:/users/username etc) but I want it to work so that other people can download the game and have it work on their machine, and other ppl prolly aint gonna put the game folder in the exact same place and defo aint gonna have the same windows username, so uh how do I get this shit to work?
No description
5 Replies
ACiDCA7
ACiDCA73mo ago
the common solution to this problem is usually either use relative paths or embed the resource also you are able to find out the absolut path of the executable where its stored and create the correct path yourself, though code
Gooburr
Gooburr3mo ago
Wow i understand basically none of this Im sorry i bet what u said is rly helpful i just dont know how to do any of that
ACiDCA7
ACiDCA73mo ago
is the image in a subfolder or right beside where the exe is?
SleepWellPupper
SleepWellPupper3mo ago
Some more details on relative paths here: https://stackoverflow.com/questions/10288223/what-is-the-difference-between-an-absolute-and-a-relative-path#10288252 Basically, absolute paths are the full location of your image, so your program can access them from anywhere else in the filesystem. Relative paths are essentially "added" to the end of your programs current location, so they describe the location of your image "relative" to your program location itself.
Stack Overflow
What is the difference between an absolute and a relative path?
I am asking because I am working on a project for school. Yes this is homework. But, I'm trying to understand a little bit more, though. This is one example of what is being asked. • When the...
SleepWellPupper
SleepWellPupper3mo ago
You could for example, store your images at /images instead of C:/users/user/game/images. This way, images would need to be located at a folder called "images" in the same directory as your game, no matter where the game itself is actually located. Alternatively, you could embed your images directly into your application file itself.
Want results from more Discord servers?
Add your server