如何在文件的同一位置恢复数据 [英] How to restore the data in the same place of a file

查看:92
本文介绍了如何在文件的同一位置恢复数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件包含...

[蔬菜]

黄瓜

番茄





[水果]

香蕉

apple







[客户]

总计= 3

[客户1]

.....

......

[客户2]

....... ...





如果我在组合框的帮助下删除了任何一个客户,更新后的列表以及所选的物品应该出现在同一个位置..



请帮帮我,我坚持删除。

My file consists of...
[Vegetables]
cucumber
tomato
.
.
[Fruits]
banana
apple
.
.

[Customer]
Total = 3
[Customer 1]
.....
......
[Customer 2]
..........


IF i delete any one of the customer with a help of combo Box, the updated list and along with the selected items should be present at the same position..

Please help me out, i stucked in deleting.

推荐答案

您不能从文本文件中删除 - 您必须创建一个新文件,从开始到删除点复制数据,跳过已删除的部分,然后将文件的其余部分复制到结束。然后将原始文件重命名为.BAK或类似名称,并将副本重命名为原始文件名。



但是...看起来像一个INI文件,它们是严重过时了。除非这是遗留数据,否则您可能不应该使用INI格式,因为有许多更好,更现代的格式。如果您必须处理它们,可以使用 WritePrivateProfileStruct [ ^ ]删除部分,它将为您完成所有这些。
You can't "delete" from a text file - you have to create a new file, copy the data from the start up to the point of deletion, skip the deleted part, then copy the rest of the file up to the end. Then rename the original as .BAK or similar, and rename the copy to the original file name.

But...that looks like an INI file, and they are seriously outdated. Unless this is legacy data, you probably shouldn't be using INI format as there are a lot of better, more modern formats. If you must process them though, you can use WritePrivateProfileStruct[^] to delete sections and it will do all that for you.


这篇关于如何在文件的同一位置恢复数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆