fit to c#
enable encode
write to file