文件操作,Io流。

 private void textBox1_TextChanged(object sender, EventArgs e)
        {
       
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String path = @"F:666.text";
//创建文件流. Stream fs = new FileStream(path, FileMode.Open);
//创建写入器. StreamReader sr = new StreamReader(fs, Encoding.Default);
//将录入的内容写入文件. string src = sr.ReadToEnd();
//关闭写入器 sr.Close();
//关闭文件流. fs.Close(); textBox1.Text = src; } }


//创建文件流.
FileStream myfs=new FileSteam(path,FileMode.Open);
//创建读取器.
StreamReader mySr=new StremReader(myfs,Encoding.Default);
//读取文件所有内容
content = mySr.ReadToEnd();
txtContent.Text=Content;
//关闭读取器.
mySc.Close();
//关闭文件流.
myfs.Close();


读取目录下的子目录信息。
private void BindInfo(TreeNode node)
{
DirectoryInfo directoryInfo =new DirectoryInfo(node.Tag.ToString());
DirectoryInfo[] dirs = directoryInfo.GetDirectories();
foreach(DirectoryInfo di in dirs)
{
TreeNode temp =new TreeNode();
temp.Text=di.Name;
temp.Tag=di.FullName;
node.nodes.Add(temp);
}
}
原文地址:https://www.cnblogs.com/2652405350wch/p/6612615.html