Is there an easy way to convert an IronPython file-like object to a .NET Stream? The reverse can be done in IronPython using code like this:
net_stream = File.OpenRead('file.txt')
python_file = file(net_stream)
Is there an easy way to convert it back? Or do you have to write a wrapper that will inherit from Stream and implement all the methods?
apparently it's possible to do it like this:
import System
f = file('abc.txt', 'w+')
f.GetType().GetField('_stream', System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic).GetValue(f)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With