RhinoDoc.WriteFile doesn't release the file after writing?


(Gabor Konstanzer) #1

There is a temp .3dm file which i’m writing with WriteFile(path, options) method. It return true, and after that i want to delete the temp file with System.IO.File.Delete(path) and it throws an exception.

Exception Message:
“The process cannot access the file ‘…Temp\RhinoTest_tmp.3dm’ because it is being used by another process.”

(Dale Fugier) #2

Hi @gabor.konstanzer,

You may need to provide some source code, that we can run here, for us to be helpful.


– Dale

(Gabor Konstanzer) #3

Okey, it is basically a Rhino 6 bare bones template in Visual Studio 2017 and i wrote this inside the RunCommand(doc, mode)

[Runcommand code in Pastebin](https://pastebin.com/nqiY8G5f)


(Dale Fugier) #4

Hi @gabor.konstanzer,

Rather than calling the document’s WriteFile member and having to deal with it’s file locking, you might just script the SaveAs command. Here is an example.


– Dale

(Gabor Konstanzer) #5

Thank you very much, i’m gonna try it tomorrow.

(Gabor Konstanzer) #6

Hi @dale

I checked your suggestion, my problem is that i’m calling the Doc.WriteFile from a service class which is saving the file temporarily and then wants to delete it. This wasn’t a problem in Rhino 5 and is a problem in Rhino 6. I think this script.runner solution is not meant to used like that. So any other suggestions why it locks longer then it used to, or how to get around the locking issue?

  • Gabor

(Dale Fugier) #7

Hi Gabor,

I have logged the issue.


Until this is resolved, you may want to use the script runner solution that I proposed (above).


– Dale

(Gabor Konstanzer) #8

Thanks, will try to do that. My question then is that i create a Scripted save Command, and i can call that command from my Plugin?

(Dale Fugier) #9


– Dale