system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
DimitriyPS |
|
Old Version |
Published before Godot 3 was released. |
I want to “user://” to create a new directory. I see document: link
I can’t find a method that would create a new directory. If possible, please show a minimal code example.
system
4
|
|
|
|
Reply From: |
eaglecat |
func _ready():
var dir = Directory.new()
dir.open("user://")
dir.make_dir("sad")
It works.
Not working for me. As is should make a sad directory in user://
star pirate | 2021-10-23 18:00
system
5
|
|
|
|
Reply From: |
Ninfur |
For anyone finding this in Godot 4.0
var dir_access = DirAccess.new()
dir_access.open("user://")
dir_access.make_dir("New Folder")
or, even simpler
DirAccess.make_dir_absolute("user://New Folder/")
Hi there. When I try to use DirAcces.new()
I get an error saying:
Line 13:Native class “DirAccess” cannot be constructed as it is abstract.Line 13:Static function “new()” not found in base “DirAccess”.
Cyber-Kun | 2023-03-31 14:04
I’m guessing the new() call was once necessary, but it isn’t anymore. It should look like this:
var dir = DirAccess.open("user://")
dir.make_dir("New Folder")
you could also use:
DirAccess.make_dir_absolute("user://path/to/your/directory")
Cyber-Kun | 2023-04-14 07:09