Calculation of disk space that a row will occupy without saving to disk

I am writing an application where I want to compare the size of two lines. By size, I mean the disk space that they would occupy if they were directly saved to disk.

Is it possible to calculate the line size in C # without saving to disk and checking file information (if only it is more efficient to save it to disk)?

+3
source share
2 answers

Yup, this is easy:

Encoding encoding = Encoding.UTF8; // Or whatever
int size = encoding.GetByteCount(text);

, . .., ( ) .

. , "" - .

+8

, , .

NTFS 16 4 , , 1 4 , 5000 8 .

MS http://support.microsoft.com/kb/140365

+2

Source: https://habr.com/ru/post/1755601/


All Articles