Notifications
Clear all

[Closed] Cannot delete file

hey there!

I try to delete a folder with this function:
(
local folderpath = @“mypath”
local sioDir = dotNetClass “System.IO.Directory”
if (SIODir.Exists folderPath) do SIODir.Delete (folderPath) true
)
this works perfectly IF there is no file which is currently used by 3ds max… otherwise it gives me this warning:
– Error occurred in anonymous codeblock; filename: ; position: 2; line: 1
– Runtime error: .NET runtime exception: The process cannot access the file ‘my_image.jpg’ because it is being used by another process.

How can I force the delete of the folder even though 3ds max is using some of its files?
Thank you!

6 Replies

Nobody has an idea?

why do you think it is even possible?

Well if I free the variable I dont see why max couldnt process the delete of the file?

I have buttons like this:

local pathImg_Script = #(dnImg.fromFile (“icon_Script_IDLE.jpg”))
dotnetcontrol bt_script “Label” pos:[656,0] width:20 height:20

on myrollout open do
bt_script.image = pathImg_script[1]

If I can “free” that dotnet button, i could free the “icon_script_idle.jpg” texture file.
I can have access to all the dotnet buttons of my rollout with: MyRollout.controls[i]

So I just need the line that would free the dotnetcontrol, make a loop and it’s done

load the images using .fromStream and won’t have this problem

fromStream instead of fromFile?
can you write the line for me? I’m not good at dotnet

thank you! :3

Check this: