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.
“The process cannot access the file ‘…Temp\RhinoTest_tmp.3dm’ because it is being used by another process.”
You may need to provide some source code, that we can run here, for us to be helpful.
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)
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.
Thank you very much, i’m gonna try it tomorrow.
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?
I have logged the issue.
Until this is resolved, you may want to use the script runner solution that I proposed (above).
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?