程序如下:
;得到画法数据. (defun C:GetDrawData ( / List1 f1 f a) ;( / DrawData1) (setq f1 "d:/ls/DrawData.txt") (setq f (open f1 "r")) (while (setq a (read-line f)) (setq a (strcat "(" a ")")) (setq a (read a)) (print(a))
(setq list1 (cons a list1))
哦,是的,那两处都错了,可是我把程序改了,我的问题依然存在,显示的结果还是:
("鎵樻灦1" 1000 235 200 "鎵樻灦" 765),不知道是怎么回事?在cad里从*.TXt文件中读回来的数据是使用什么编码呀。
(defun C:GetDrawData ( / List1 f1 f a) ;( / DrawData1) (setq f1 "d:/ls/DrawData.txt") (setq f (open f1 "r")) (while (setq a (read-line f)) (setq a (strcat "(" a ")")) (setq a (read a)) (print a )
(setq list1 (cons a list1))
我都试过了,
System.Text.Encoding.ASCII
System.Text.Encoding.BigEndianUnicode
System.Text.Encoding.Unicode
和UTF8 和UTF7
都试了,都不行。代码有问题吗?我代码是:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click On Error Resume Next
Dim i, j As Integer Dim StrDrawData(5) As String Dim Str1 As String
Dim StrPath = "d:\ls\DrawData.txt" Dim FStream1 As FileStream FStream1 = File.Open(StrPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read) Dim SW1 As New StreamWriter(FStream1, System.Text.Encoding.ASCII) 'SW1.NewLine = "\r\n"
With C1FlexGrid2 For i = .Rows.Fixed To .Rows.Count - 1 For j = .Cols.Fixed To .Cols.Count - 1 If .Cols(j).DataType.ToString = "System.String" Then StrDrawData(j - 1) = """" & .GetDataDisplay(i, j) & """" Else StrDrawData(j - 1) = .GetDataDisplay(i, j) End If Next
Str1 = Str1.Join(" ", StrDrawData) SW1.WriteLine(Str1) 'SW1.NewLine = "\r\n" 'MsgBox(Str1) Next End With
SW1.Close() FStream1.Close()
MsgBox("ok")