[Closed] Unable to close filestream with 3dsMax 2012
The title describes pretty much whats happening. The following code works with all versions but 2012.
new_file = createFile "C:\ est.tmp"
theString = "HA-HA"
format "%
" theString to:new_file
close new_file
Well it does kinda work. But the filestream is not really closed. If I use a program such as Unlocker I can clearly see that 2012 has the file locked, whereas previous versions unlock the file after using “close”. Quite annoying… Is anyone else having this problem? Or is there any workaround?
Thanks!
Yes it’s a known bug, seems to be a workaround though :
http://forums.cgsociety.org/showpost.php?p=6950551&postcount=3
had similar problem with binstream in max 2010…
calling:
fflush file
before closing the file seems to work in that instance, no idea it would work in 2012 filestream case
just tried it and using “flush” and then “close” still keeps the file locked.
Instead I’m using this:
http://forums.cgsociety.org/showpost.php?p=6950591&postcount=5
The problem I had with the dotnet version was the encoding(at least that’s what I’ve guessed), I had a string with tabs and CRLF and so on and was displaying correctly in the listener but once written with dotnet it got the file screwed up
I think you can change the encoding:
http://msdn.microsoft.com/en-us/library/ms143376.aspx
http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx
It seems to let me delete files used by filestreams if I close filestreams and then resetmaxfile()
Feels a little clunky – Is there another way? flush and fflush doesnt work for me as mentioned.
Yeah, a nasty bug on the shipping Max 2012 version caused a file to be opened twice internally, but to be closed just once, resulting in file locking.
Until the Hotfix was posted, it wasn’t usable for me (or anyone else depending on MAXScript), in fact Thinkbox did not support Deadline on 2012 until the fix was provided.