标题:BinaryWriter 的简单问题,谁帮忙看下
取消只看楼主
moridiansha
Rank: 6Rank: 6
来 自:承德
等 级:侠之大者
威 望:4
帖 子:254
专家分:417
注 册:2009-10-21
结帖率:75%
已结贴  问题点数:20 回复次数:0 
BinaryWriter 的简单问题,谁帮忙看下
class Program
    {   
        /// <summary>
        /// 写入文件
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Console.WriteLine("请输入文件名:");
            string filename = Console.ReadLine();
            FileStream fs;//声明FileStream对象
            try
            {
                fs = new FileStream(filename, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write('a');
                bw.Write("liuxiaoxiaoying");
                bw.Write(123456);
                bw.Write(456.789);
                Console.WriteLine("成功写入");
                bw.Close();
                fs.Close();
            }
            catch (IOException ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
    }
但写入进去的只有字符,和字符串,数字进去后是乱码,但书上写的是可以写入数字
搜索更多相关主题的帖子: BinaryWriter 简单问题 
2010-04-18 10:23



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-303455-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053233 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved