回 帖 发 新 帖 刷新版面

主题:我是菜鸟|为什么不能编译?

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)
        {
            

        }

        private void Form1_Load(object sender, EventArgs e)
        {
         File f = new File("D:\a.ini");
            StreamReader strim = f.OpenText();
            string s;
            s = strim.ReadLine();
            while (s != null)
            {
                listBox1.Items.Add(s);
                s = strim.ReadLine();

            }
            strim.close;
        }
    }
}

回复列表 (共3个回复)

沙发

怎么没有人回答啊
c#这边人气不好啊!!!1

板凳

错误提示是什么?

3 楼

using System;
using System.IO;
class Test
{
    static void Main() {
        using (TextWriter w = File.CreateText("log.txt")) {
            w.WriteLine("This is line one");
            w.WriteLine("This is line two");
        }
        using (TextReader r = File.OpenText("log.txt")) {
            string s;
            while ((s = r.ReadLine()) != null) {
                Console.WriteLine(s);
            }
        }
    }
}

我来回复

您尚未登录,请登录后再回复。点此登录或注册