[Python.NET] Getting an open Python file handle into CLR

Dan Lenski dlenski at gmail.com
Wed Jul 22 00:54:50 CEST 2015


Jeffrey Bush <jeff at ...> writes:

> 
> 
> The problem is the conversion from a Python long to a C# number, not 
anything to do with the file handle itself.
> This worked for me: (after your "print handle")
> 
> 
> cs_handle = IntPtr.Overloads[Int64](Int64(handle))
> fs = FileStream(cs_handle, True)
> 

Aha, thanks you very much!

Looks like "Overloads" is the missing ingredient for C-style casting. I 
see now that that is in the docs, but I had overlooked it.

Dan



More information about the PythonDotNet mailing list