C#读写文件的例子
现在有一个1.txt文件,内容是一个1,用二进制的方式把他读到另外一个文件2.txt中是49,不知道为什么是49(这个不重要),然后读2.txt文件,要读到的内容是1,怎么样读呢。读到的变量data是49,求救啊!!!!!!!!!!!
string pathbody = @"C:\Documents and Settings\Administrator\桌面\新建文件夹 (2)" + "\\1.txt";
string pathheader = @"C:\Documents and Settings\Administrator\桌面\新建文件夹 (2)" + "\\2.txt";
byte[] arrFile=null;
using (FileStream fs2 = new FileStream(pathbody, FileMode.Open))
{
arrFile= new byte[1];
fs2.Read(arrFile, 0, 1);//读1.txt的文件
using (StreamReader sr = new StreamReader(fs2))
{
using (StreamWriter sw1 = new StreamWriter(pathheader, true))
{
for (int i = 0; i < 1; i++)
{
sw1.Write(arrFile[i]);
}
}
}
}
using (FileStream fsBody = new FileStream(pathheader, FileMode.Open, FileAccess.Read))
{
using (StreamReader sw1 = new StreamReader(fsBody))
{
string str = sw1.ReadLine();
byte[] demo = System.Text.Encoding.Default.GetBytes(str);
string data = System.Text.Encoding.Default.GetString(demo);
}
}
string pathbody = @"C:\Documents and Settings\Administrator\桌面\新建文件夹 (2)" + "\\1.txt";
string pathheader = @"C:\Documents and Settings\Administrator\桌面\新建文件夹 (2)" + "\\2.txt";
byte[] arrFile=null;
using (FileStream fs2 = new FileStream(pathbody, FileMode.Open))
{
arrFile= new byte[1];
fs2.Read(arrFile, 0, 1);//读1.txt的文件
using (StreamReader sr = new StreamReader(fs2))
{
using (StreamWriter sw1 = new StreamWriter(pathheader, true))
{
for (int i = 0; i < 1; i++)
{
sw1.Write(arrFile[i]);
}
}
}
}
using (FileStream fsBody = new FileStream(pathheader, FileMode.Open, FileAccess.Read))
{
using (StreamReader sw1 = new StreamReader(fsBody))
{
string str = sw1.ReadLine();
byte[] demo = System.Text.Encoding.Default.GetBytes(str);
string data = System.Text.Encoding.Default.GetString(demo);
}
}
...全文
OrthoFinder功能、流程和文件注释 OrthoFinder 的标准输出包括:直系同源组,直系同源基因,有根基因树,解析基因树,无根物种树、有根物种树,基因重复事件以及相关的统计数据。 阅读详情
相关推荐
C#中读写INI文件的方法例子
通常C#使用基于XML的配置文件,不过如果有需要的话,比如要兼顾较老的系统,可能还是要用到INI文件。但C#本身并不具备读写INI文件的API,只有通过调用非托管代码的方式,即系统自身的API才能达到所需的目的。 对应读写的方法分别为GetPrivateProfileString和WritePrivateProfileString。 GetPrivateProfileString中的各参数:lpAppName —— section的名称lpKeyName —— key的名称lpDefault —— 如果lpKeyName没有被找到的话,则将这个值复制到lpReturnedString中lpRe
C#读写INI文件例子
C#读写INI文件例子,仅供大家参考学习。
C#文件读写操作的例子
C#关于文档操作的一个小例子,应该比较实用
C#读写二进制文件的例子
C#读写二进制文件的例子,包括读操作和写操作,全部源代码。
C#读写Influxdb代码例子
C#读写Influxdb代码示例源代码,简单、易用,新手可直接调用InfluxDBHelper,有其他方法的欢迎一起讨论学习


