If I understand your question then decreasing size of LDF file through C# code is not doable.
Reason: LDF file is getting generated by database instance. This transaction logs file's format is getting maintain by SQL server instance. This is like, can you reduce size of PDF file, Doc file through just C# code without any vendor component.
Yes for sure you can write a program which connects to database instance and can perform below actions.
SQLDatabase.TransactionLog.Truncate();
SQLDatabase.Shrink(5, SQLDMO.SQLDMO_SHRINK_TYPE.SQLDMOShrink_NoTruncate);
SQLDatabase.TransactionLog.Truncate();
SQLDatabase.Shrink(5, SQLDMO.SQLDMO_SHRINK_TYPE.SQLDMOShrink_Default);
If you are decreasing file size to archiving it then simply write a program to Zip (Compress) it, it will work and will be easy also.
-- Thanks Rushi