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 }
时间: 2024-11-01 08:29:55