Notifications
Clear all

[Closed] Translate C# to maxscript of StandardInput.BaseStream, Encoding.UTF8

Hi,
I have a little problem of handing DotNetObject “System.Diagnostics.Process”,I searched the net and found nothing about it with maxscript,there are lots of sample of C#,I don’t know C# at all,so my problem is how to define the StandardInput and StandardOnput stream to UTF8 from C# to Maxscript?
Here I got a sample of handling cmd using “System.Diagnostics.Process”

Fn Handingcmd CommandString = 
(
    DotNetHandle = DotNetObject "System.Diagnostics.Process"
    DotNetHandle.StartInfo.WindowStyle=(DotNetClass  "System.Diagnostics.ProcessWindowStyle").Hidden
    DotNetHandle.StartInfo.CreateNoWindow= true
    DotNetHandle.StartInfo.UseShellExecute= false
    DotNetHandle.StartInfo.RedirectStandardInput = true;
    DotNetHandle.StartInfo.RedirectStandardOutput = true;
    DotNetHandle.StartInfo.FileName = "cmd.exe"
    DotNetHandle.Start()
    DotNetHandle.StandardInput.WriteLine(CommandString )
    DotNetHandle.StandardInput.WriteLine("exit")
    DotNetHandle.WaitForExit(5000);
    CmdOutput = DotNetHandle.StandardOutput.ReadToEnd()
    CmdOutput
)
Handingcmd ("dir c:\\ >d:\\き.txt")

If the command line has none English character,such as a Japanese “き”,it should runs OK on win7,and create a “き.txt”,but fail on winxp,I changed to

doscommand ("dir c:\\ >d:\\き.txt")

works fine on winxp,so I think it might be the Encoding reason,then I added the codes like below,but still unlucky,doesn’t work:

Fn Handingcmd CommandString = 
(
    DotNetHandle = DotNetObject "System.Diagnostics.Process"
    DotNetHandle.StartInfo.WindowStyle=(DotNetClass  "System.Diagnostics.ProcessWindowStyle").Hidden
    DotNetHandle.StartInfo.CreateNoWindow= true
    DotNetHandle.StartInfo.UseShellExecute= false
    DotNetHandle.StartInfo.RedirectStandardInput = true;
    DotNetHandle.StartInfo.RedirectStandardOutput = true;
    DotNetHandle.StartInfo.FileName = "cmd.exe"
    DotNetHandle.Start()
	
	DotNetHandle.StandardInput.Encoding.UTF8
	DotNetHandle.StandardOutput.CurrentEncoding.UTF8
	
    DotNetHandle.StandardInput.WriteLine(CommandString )
    DotNetHandle.StandardInput.WriteLine("exit")
    DotNetHandle.WaitForExit(5000);
    CmdOutput = DotNetHandle.StandardOutput.ReadToEnd()
    CmdOutput
)
Handingcmd ("dir c:\\ >d:\\き.txt")

It seems need StandardInput.BaseStream, Encoding.UTF8, not the DotNetHandle.StandardInput.Encoding.UTF8,so how to translate it?
Or maybe not this reason cause the problem?