StreamWriter使用时的报错情况:

stream was not readable.

错误原因:

没有指定StreamWriter的写入文件

正确代码示例1:

byte[] businessDataByte = dh.downFile(dataActionUrl);
logger.InfoFormat("{0}", businessDataByte.Length);

StreamWriter sw = new StreamWriter("a.txt"));
sw.Write(Encoding.UTF8.GetString(businessDataByte));
sw.Flush();
sw.Close();

示例2:

using System;
using System.IO;
using System.Text;

namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
string fileName = "test.txt";
string textToAdd = "Example text in file";

using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
{
using (StreamWriter writer = new