- 最後登錄
- 2024-3-16
- 在線時間
- 0 小時
- 註冊時間
- 2008-9-26
- 閱讀權限
- 95
- 精華
- 0
- UID
- 5026183
- 帖子
- 318
- 積分
- 1172 點
- 潛水值
- 27226 米
| 本帖最後由 arthurliuliu 於 2013-5-23 04:48 PM 編輯
請問各位大大...
以下是我的程式碼
可以麻煩各位大大幫小弟看看哪邊出錯
因為小弟上網去找都沒有找到相關訊息說改掉某一段就可以讀中文
煩請各位大大幫忙~感恩!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- namespace WindowsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- FileStream MyFile;
- byte[] buffer = new byte[100];
- string Filedata;
- int TotalBytes; //檔案中的資料長度
- MyFile = File.Open("try.txt", FileMode.Open);
- TotalBytes = MyFile.Read(buffer, 0, (int)MyFile.Length);
- System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding();
- Filedata = Encoding.GetString(buffer, 0, TotalBytes);
- MyFile.Close();
- label1.Text = Filedata;
- }
- }
- }
複製代碼 ... |
|