码迷,mamicode.com
首页 > 编程语言 > 详细

文件操作c/c++/c#

时间:2015-01-18 11:42:35      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

1 c 文件操作  http://www.cnblogs.com/duzouzhe/archive/2009/10/24/1589348.html

2 c++文件读写  http://blog.csdn.net/kingstar158/article/details/6859379

3 c#读写  http://www.cnblogs.com/blsong/archive/2010/10/10/1847063.html

4 C#流(stream)   http://www.cnblogs.com/liuxinls/archive/2013/02/15/2912968.html

 

使用实例

 1 char * buffer;
 2 long size = 1;
 3 ifstream file (filepath.c_str(),ios::in|ios::binary|ios::ate);
 4 if(file.is_open())
 5 { 
 6 size = file.tellg();
 7 file.seekg (0, ios::beg);
 8 buffer = new char[size];
 9 file.read (buffer, size);
10 file.close();
11 
12 
13 ofstream fst(filepath.c_str(),ios::out|ios::trunc);
14 if(fst.is_open() && buffer[2]!=x && buffer[3]!=m && buffer[4]!= l)
15 {
16 fst <<"the file begin";
17 for(int i =0;i<size;++i)
18 fst<<buffer[i];
19 fst<<"the file end";
20 fst.close();
21 }else
22 {
23 for(int i =0;i<size;++i)
24 fst<<buffer[i];
25 fst.close();
26 }
27 delete [] buffer;
28 }else
29 {
30 return S_FALSE;
31 }‍

 

文件操作c/c++/c#

标签:

原文地址:http://www.cnblogs.com/nightcatcher/p/4231548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!