我想删除缓冲区文件,由比例尺中的值填充。 到目前为止,这是我的代码。但是在达到定义的文件大小后,它会删除整个文件。
.parent {
border: 1px solid orange;
padding: 20px;
width: 400px;
}
.parent .child {
display: inline-block;
height: 40px;
background: blue;
transition: width 0.5s ease 600s;
width: 10px; /* why does this value has to be different ... */
/* Hint:
If you hover the child until it reaches the 100px, then hover the
parent without leaving the parent and keeping that hover for the
transition-delay (600s) the width will become 10px as defined here.
And removing this width property here won't make the transition work
at all. */
}
.parent .child:hover {
transition-delay: 0s;
width: 100px;
}
.parent:not(:hover) .child {
transition: width 0.5s ease 0s;
width: 11px; /* ... from this value? */
/* Hint:
This is used as some kind of interruption of the 600s
transition-delay in order to achieve the parent un-hover effect.
I would like to set the width to 10px here as well but this will
result in having no effect on the width of the enlarged child when
un-hovering the parent. */
}
我相信有更好的方法。不删除整个文件并保留其中的las值。但是怎么样? 希望有人可以提供帮助。
答案 0 :(得分:1)
如果要从文件中删除前几个值,最好的方法是将其余值复制到第二个文件。然后,您可以使用新文件覆盖原始文件。这是一些示例代码。
const string yourfile = "buffer1";
const string tempfile = "buffer1edit.bin";
System.IO.FileInfo fi = new System.IO.FileInfo(yourfile);
if (fi.Length > 50)
{
using (System.IO.FileStream originalfile = System.IO.File.Open(yourfile, System.IO.FileMode.Open),
newfile = System.IO.File.Open(tempfile, System.IO.FileMode.CreateNew))
{
originalfile.Seek(50, System.IO.SeekOrigin.Begin);
originalfile.CopyTo(newfile);
}
System.IO.File.Delete(yourfile);
System.IO.File.Move(tempfile, yourfile);
}