private string Patch(string value, int maxLength)
        {
            if (string.IsNullOrEmpty(value)) return "".PadRight(maxLength);
            return value.Length <= maxLength ? value.PadRight(maxLength) : value.Substring(0, maxLength);
        }

        private string PatchCurrency(string value, int maxLength)
        {
            if (string.IsNullOrEmpty(value)) return "0.00".PadLeft(maxLength, '0');
            return value.Length <= maxLength ? value.PadLeft(maxLength, '0') : value.Substring(0, maxLength);
        }
 String record = String.Format("{0}\t{1}\t{2}\t{3}\t{4}",
	Patch(item.Id, 12),
        Patch(item.Name, 90),
        PatchCurrency(Convert.ToDecimal(item.Amount).ToString("0.00"), 9),
        Patch(Convert.ToDateTime(item.Date).ToString("MM/dd/yyyy"), 10),
        Patch(Convert.ToDateTime(item.Date).ToString("hh:mmtt"), 8),
 );
Last modified: July 19, 2019

Author

Comments

Write a Reply or Comment