There is a file on disk, which can be very large. Is there a way to remove the last N bytes from it without copying the remaining contents to another file?
What about this C # .NET code snippet?
FileInfo fi = new FileInfo("filename"); FileStream fs = fi.Open(FileMode.Open); long bytesToDelete = 5000; fs.SetLength (Math.Max(0, fi.Length - bytesToDelete)); fs.Close();
In addition, if you want to add or remove bytes at any position: Insert, delete a place anywhere in the file without temporarily copying files