Calling .Net functions
I'm trying to write a script that does a SHA1 check on a file and I understand the .Net calls that I need to call but for the life of me I can't get it working in maxscript. Can anyone help me finish it?
The first problem is the file delme#.txt never gets closed. I'm pretty sure I need to call stream.Close() but I can't get it to work.
The second is running byte = hashClass.ComputeHash(fileStream, FileMode.Open)
How do I store a byte array in maxscript?
fn SHA filename = ( if doesFileExist filename then ( fileMode = dotNetClass "System.IO.FileMode" print (fileMode.Open as string) stream = dotNetObject "System.IO.FileStream" filename fileMode.Open hashClass = dotNetClass "System.Security.Cryptography.SHA1CryptoServiceProvider" hash = hashClass.ComputeHash stream -- Try unsucessfully to close the stream showMethods stream dotNetObject "System.Security.Cryptography.SHA1CryptoServiceProvider.Close" dotNetObject "System.IO.FileStream.Close" ) ) SHA "c:/DelMe6.txt"