[Closed] dotnet exception error
I run this code from a folder which also has the bmp file in it but I get a message which says a dotnet exception has occurred in relation to the ‘target_large.bmp’ file.
However if I move the script and file to another location and run it again, it runs fine.
I don’t understand why.
theImage = dotNetClass "System.Drawing.Image"
theBitmap = theImage.FromFile "target_large.bmp"
i think the short answer is to use full paths with the FromFile method. I will edit this post later with more details when i have a moment.
yes I tried putting in the full file path but same error… in any case, this is no solution as I want the user to not need to do this…The trouble is, in maxscript, there is no issue…it assumes the file is in the same folder as the script, but dot net is full of minor annoyances like this… I wonder why I bother with it
in that case if the image is always going to be in the same folder as the script then you can take advantage of the getSourceFilename() function
theDir = getFilenamePath ( getSourceFilename() )
theFilename = "target_large.bmp"
theImage = dotNetClass "System.Drawing.Image"
theBitmap = theImage.FromFile (theDir + theFilename)
I will try that then…thank you very much, sir…I see you live in sydney…may I ask what field you work in?