C# 创建目录

C#创建目录
var strpatj = HttpRuntime.AppDomainAppPath;
if (!Directory.Exists(strpatj+"\\temp"))
Directory.CreateDirectory(strpatj + "\\temp");
C#在目录下创建文件
StreamReader sr = new StreamReader(filestrem, System.Text.Encoding.GetEncoding("gb2312")); //读取这个流
using (StreamWriter sw = new StreamWriter(strpatj + "\\temp\\" + "temp.csv"))
{
sw.Write(sr.ReadToEnd()); //读取后, sr无数据
}

//带编码方式写入
using (StreamWriter sw = new StreamWriter(strpatj + "\\temp\\" + "temp.csv", false, Encoding.GetEncoding("gb2312")))
{
sw.Write(sr0.ReadToEnd());
}



//在读取该文件,返回一个Stream.
StreamReader sr1 = new StreamReader(strpatj + "\\temp\\" + "temp.csv", System.Text.Encoding.GetEncoding("gb2312")); //读取这个流
filestrem =  sr1.BaseStream;


//未测试
using (FileStream fsw = new FileStream(strpatj + "\\temp\\" + "temp.csv", FileMode.Create, FileAccess.Write))  //打开文件,用于只写??
{
BinaryWriter bw = new BinaryWriter(fsw); //编写器指向这个文件流??
bw.Write(System.IO.File.ReadAllBytes(strpatj + "\\temp\\" + "temp.csv"));    //打开一个文件读取流信息,将其写入新文件??
System.IO.File.Delete(path + i.ToString() + "_" + filename);        //删除指定文件信息??
bw.Flush(); //清理缓冲区??
}

 

转载于:https://www.cnblogs.com/enych/p/11083934.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值