question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Directory.SetCurrentDirectory() causes script reloading to fail.

See original GitHub issue

Please note: ScriptHookVDotNet is NOT ScriptHookV! If you get a FATAL error (e.g. FATAL: Unknown game version after a game update), than this project is not responsible and you instead need to wait for ScriptHookV to update.


Version SHVDN 2.10.10 version from 3.0.3

Description I am creating a file browser class for use in a mod I am working on. I changed the directory in the mod with the Directory.SetCurrentDirectory() command. When I hit insert to reload the scripts, it fails because it is now looking for the scripts folder inside the directory I changed to.

I wouldn’t have thought that this command would have affected SHVDN, as I presumed it got its base directory from a path relative to the game folder but it seems it does.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
LeeC2202commented, Apr 26, 2020

“One could argue that using Directory.SetCurrentDirectory is ill adviced as well”.

Nobody argued that anything was ill-advised (note the spelling), it was suggested that it might be better to do something in an alternate way… put your ego away!

And it’s very nice (and unsurprising) of you all to jump on the ill-advised bandwagon, while neglecting the fact that assuming a relative directory stays intact is just as ill-advised, if not more so. If you need something to be in a certain place, then it’s your job to ensure it is… That’s why professional applications let you set absolute paths to essential directories, instead of just assuming relative ones. It’s why the game has a registry key that doesn’t say …\Rockstar Games\Grand Theft Auto V it gives the full, absolute path.

You don’t need to question why I do anything I do, nor are any of you qualified to do so… you need to question why something in your system stops working when something happens. I called a function, SHVDN stopped working, that’s the only relevant factor. Whether it was wrong or right of me to call that function has no relevance whatsoever, because my system is full of hundreds of applications that might do it as well.

And I suggest some of you remember the saying about throwing stones and glass houses before pointing fingers. Trust me, there’s enough “ill-advised” going on in the world of API and mod development with SHVDN already. Take the blinkers off every now and again, SHVDN and GTA5 aren’t the only things on everyone’s PC.

Closed because I’m not being the subject of further hypocritical finger-pointing.

0reactions
Tanjitsucommented, Apr 22, 2020

I would have to agree that using Directory.SetCurrentDirectory in a mod seems like the wrong choice. I would assume setting the directory is an environment level change and not something which would be used in a framework such as this.

Why would you need to force the system to use a different location as the “current” location ? It would seem more logical to just have the path to the chosen location and work with it leaving the actual current location intact.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set-Location versus SetCurrentDirectory - powershell
When I changed directory using Set-Location I got an error (one that was specific to the assembly) complaining it could not find all...
Read more >
Directory.SetCurrentDirectory(String) Method (System.IO)
When the application terminates, the working directory is restored to its original location (the directory where the process was started). The path parameter...
Read more >
[solved]LoadLibrary unable to load a library even when ...
All I needed to do was change the current directory using SetCurrentDirectory . (And put things back at the end of the function...
Read more >
Inconsistent current directory when running dotnet-test-xunit
GetDirectoryName requires an OS-normalized value or else the OS-dependent directory separator char will cause a failure. I use AppContext.
Read more >
Reloading Scripts Behavior
Is the reload scripts command (default F8), only reloading the base script folder built-in with the Blender install.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found