There's a file on disk which can be very large. Is there any way to delete the last N bytes from it without copying the remaining content to another file?
+3
A:
How about this fragment of C# .NET code?
FileInfo fi = new FileInfo("filename");
FileStream fs = fi.Open(FileMode.Open);
long bytesToDelete = 5000;
fs.SetLength (Math.Max(0, fi.Length - bytesToDelete));
fs.Close();
John Knoeller
2010-02-06 09:53:24
thanks, didn't thought of that
Sandu
2010-02-06 21:08:20
A:
Additionally, if you want to add or remove bytes at any position: Insert, delete space at any place in file without making temporary file copy
Quazistax
2010-03-30 20:03:28