文件与流

        public byte[] FileToStream(string path)
        {
            byte[] s = null;
            StreamReader reader = new StreamReader(path);
            s = File.ReadAllBytes(path);
            return s;
        }

        public void StreamToFile(string path, byte[] bytes)
        {
            FileStream stream = null;
            stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
            stream.Write(bytes, 0, bytes.Length);
            stream.Close();
        }

posted @ 2013-12-10 17:28  pnljs  阅读(207)  评论(0编辑  收藏  举报