CreateFolder without parent has no ioexception?

Just checking to see if I can generate a weird situation.
I first noticed some folders weren’t being created.
After wondering what I’d done to do this, I remembered deleting a CreateFolder line because it was creating folders with the wrong names.

Oh I forgot to add it back in.
So I checked on the parent of the folder I wanted to create, and it didn’t it exist.
I then noticed I’m not getting an ioexception error on CreateFolder.

So. My question is do I have a weird situation. If the Parent to a folder that is being created does not exist, do YOU get an ioexception?

Show us your code?

If tf = Nil Or Not tf.Exists Then tf.CreateFolder

tf doesn’t exist, but I found out neither does the parent.

What do you expect that the above code does? How does your complete code look like? Please describe your problem more fully. For instance, here is a bug with aliases and folderitems and a full description: <https://xojo.com/issue/59530>

Under normal circumstances, the above line creates the folder.

Here’s a more complete example including the problem.

Var gf as folderitem = SpecialFolder.documents.child("top") var tf as folderitem = gf.child("bottom")//gf doesn't exist If tf = Nil Or Not tf.Exists Then tf.CreateFolder

I just tested this by putting it in at the top of my app, and it didn’t even blink.
BTW I tried CreateAsFolder too.

Can someone else test this?

I’d try this code written as

Var gf as folderitem = SpecialFolder.documents.child("top")
var tf as folderitem = gf.child("bottom")//gf doesn't exist
If (tf is Nil) Or (Not tf.Exists) Then 
  break
  tf.CreateFolder
end if

and see if you actually stop at the break statement
one of the reasons NOT to use oneliners :slight_smile:

FWIW here when I run that code and it does hit the break it DOES appear to create the top dir as well
But that fails - the variable does have the right path though
I would think that there should be an exception or something - but last error code is also still 0

dim gf as folderitem = SpecialFolder.documents.child("top") if gf = nil or not gf.exists then messagebox "error here" return end if gf = gf.child("bottom")

Not a bug.

If gf doesn’t exist, then tf should be nil. I don’t think your CreateFolder is being executed at all.

That might be the Apple solution to the problem, and the reason why the ioexception isn’t generated.

I also made a simple project, and on Mac nothing happened.

I finally got to my PC to do the same few lines of code and it generated a nilobject.

It is apparently