问题描述
伙计们
我正在尝试使用c Sharp将文本文件发送到调制解调器.
在调制解调器手册中,它指定:在ASCII设置中使用发送文本"文件:在启用了超级终端属性的情况下,将带有换行符的行末尾和将换行符追加至传入的行尾.
您如何看待这些属性会影响要发送的文本文件?
这是我用来发送文本文件的代码.
port.StopBits = StopBits.One;
port.Parity = Parity.None;
port.Encoding = System.Text.Encoding.GetEncoding(1252);
port.DtrEnable = true;
port.RtsEnable = true;
port.Handshake = Handshake.RequestToSend;
StreamReader readtext =新的StreamReader("filename.txt");
字符串内容= readtext.ReadToEnd();
readtext.Close();
readtext.Dispose();
byte [] WriteBuffer =新的byte [contents.Length];
ASCIIEncoding enc =新的System.Text.ASCIIEncoding();
WriteBuffer = enc.GetBytes(contents);
port.Write(WriteBuffer,0,contents.Length); <pre></pre>
Hi Guys
I am trying to send a text file to a modem using c sharp.
In the modem manual it specifies: use Send Text file with ASCII Setup: Send line ends with line feeds and Append line feeds to incoming line ends in HyperTerminal Properties enabled.
How do you think these properties affect the text file to be sent??
Here is my code I am using to send the text file.
port.StopBits = StopBits.One;
port.Parity = Parity.None;
port.Encoding = System.Text.Encoding.GetEncoding(1252);
port.DtrEnable=true;
port.RtsEnable = true;
port.Handshake = Handshake.RequestToSend;
StreamReader readtext = new StreamReader("filename.txt");
string contents = readtext.ReadToEnd();
readtext.Close();
readtext.Dispose();
byte[] WriteBuffer=new byte[contents.Length];
ASCIIEncoding enc = new System.Text.ASCIIEncoding();
WriteBuffer = enc.GetBytes(contents);
port.Write(WriteBuffer, 0,contents.Length );<pre></pre>
推荐答案
这篇关于通过串口发送文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!