thats my code
static void Write(DataTable dt, string outputFilePath)
{
int[] maxLengths = new int[dt.Columns.Count];
for (int i = 0; i < dt.Columns.Count; i++)
{
maxLengths[i] = dt.Columns[i].ColumnName.Length;
foreach (DataRow row in dt.Rows)
{
if (!row.IsNull(i))
{
int length = row[i].ToString().Length;
if (length > maxLengths[i])
{
maxLengths[i] = length;
}
}
}
}
using (StreamWriter sw = new StreamWriter(outputFilePath, false))
{
sw.Write(new byte[]{0xff,0xfe});
foreach (DataRow row in dt.Rows)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
if (!row.IsNull(i))
{
sw.Write(row[i].ToString() + " ");
}
}
sw.WriteLine();
}
}
}
i want to put 2 bytes to the text file at the beginning.
sw.Write(new byte[]{0xff,0xfe});
the problem is when i open with hex i don't see those 2 bytes.
but i see on the text file itself these :\
any solution please help.
its suppose to look like this