如何修改文件内的内容? [英] How to modify the contents inside the file?
本文介绍了如何修改文件内的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要修改文件内的内容。
我们在第一行有日期和时间一些数字和Guid和CRC计数。
Ex:2015 / 02/02 09:05:26 123456.35625 ADXBH789-YU78-YUG7-KL9I-ADJKH789 78
每次如果我按下按钮第一行应该用CurrentDate&Time和Numbers NewGuid和New CRC改变。
任何人都可以帮我解决这个问题。
使用MFC VC ++
I need to modify the content inside the files.
Inside we have First line having the date and time some number & Guid's and CRC count.
Ex:2015/02/02 09:05:26 123456.35625 ADXBH789-YU78-YUG7-KL9I-ADJKH789 78
In Each time if i press The Button The First Line should changed with CurrentDate &Time and Numbers NewGuid's and New CRC.
Can anyone help me to solve this.
Using MFC VC++
推荐答案
如果您的数字是固定长度,那么它非常简单:只需打开文件进行读写访问,将新信息写入文件(确保它是固定大小的写入而不是基于行),关闭文件。
如果你的号码不是一个固定的长度,那就更糟糕了:
打开火来阅读,打开一个新文件写。
阅读第一行并丢弃。
写下新的第一行。
复制文件的其余部分。
关闭这两个文件。
If your number is fixed length, then it's pretty simple: just open the file for read-write access, write the new information into the file (making sure it's a fixed size write rather than line based), close the file.
If your number is not a fixed length, then it's a lot nastier:
Open the fire for read, open a new file for write.
Read the first line and discard.
Write the new first line.
Copy the rest of the file.
Close both files.
这篇关于如何修改文件内的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文