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 in a text file at the beginning.
sw.Write(new byte[]{0xff,0xfe});
The problem is that I open with hexadecimal, I do not see these 2 bytes. but I see in the text file these
: \
any solution please help. suppose it looks like
source
share