[module] Unsure how to properly use ChangeDirectory()
See original GitHub issueSo, I’m using Raylib-CS on macos, so that might be pertinent. Right now, for loading assets I am using a solution I picked up from using Monogame. It goes something like this: Check “copy to output directory” on all assets (images etc). Then I use this function whenever I’m loading a file:
static string getFullPath(string relativePath)
{
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
return System.IO.Path.Combine(baseDirectory, relativePath);
}
Font ALAGARD = LoadFont(getFullPath("Assets/fonts/alagard.png"));
Image cursorImage = LoadImage(getFullPath("Assets/cursor.png"));
This works for me, but I’ve been made aware that another solution would be to call ChangeDirectory(GetApplicationDirectory());
The issue is, I don’t know how to use this function properly with C#. I get the following errors:
Again, what I was already doing works, but I’m curious how to use these functions properly. It doesn’t seem like using “unsafe” should be required. I feel that I am missing something obvious here, any help would be appreciated!
Issue Analytics
- State:
- Created 3 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How do I change directory back to my original working ...
The best solution is to use the subprocess module instead (Python 2.4 onwards) and the run or popen methods with the cwd argument....
Read more >The Module Search Path
In this lesson, you'll learn about the module search path. Continuing with the example from the previous lesson, take a look at what...
Read more >Changing Directory based on user input - Python Forum
Hi there, I'm trying to create a program whereby a user can resize images in their own, inputted directory. As you can see...
Read more >How to set up working directory in PyCharm and package ...
I want 2 questions: 1) I want to import the file lr_utils.py as a package, it's in my current directory. PyCharm refuse to...
Read more >Moving Into and Out of Directories with the "cd" Command
The second way to list files in a directory, is to first move into the directory using the "cd" command (which stands for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@differenceclouds Oh, the
ref
keyword is common in C#: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/refWhen you use
void ImageRotateCW(ref Image image)
for example, the with and height of the image change and in order to update the fields, you have to provide a reference.That’s because Image is a struct and not a class.
Have a look at
Utf8StringUtils
it allows you to convert pointers to strings and back.As for the current directory, try and prefer the built-in C# methods, e.g.
System.Numerics
over RayMath,AppDomain.CurrentDomain.BaseDirectory
orAssembly.GetExecutingAssembly().Location
overraylib.GetApplicationDirectory
, etc.