I saw some questions here related to removing double quotes. But it not solved my Issue. They told to use Replace or Trim functions. I used but the problem remains.
My code:
DataTable dt = TypeConveriontHelper.ConvretExcelToDataTable(SourceAppFilePath);
string targetPath = BatchFolderPath + @"\" + "TRANSACT.INX";
StreamWriter wrtr = null;
wrtr = new StreamWriter(targetPath);
for (int x = 0; x < dt.Rows.Count; x++)
{
string rowString = "";
for (int y = 0; y < dt.Columns.Count; y++)
{
if (y == dt.Columns.Count - 1)
{
rowString += "\"" + dt.Rows[x][y].ToString() + "\"";
}
else
{
rowString += "\"" + dt.Rows[x][y].ToString() + "\"~";
}
}
rowString.Replace('"', ' ').Trim();
wrtr.WriteLine(rowString);
}
wrtr.Close();
wrtr.Dispose();
I tried by using rowString.Replace('"', ' ').Trim();
in above code. But double quotes are present as it is. Proveide me a solution. Thanks.
using
statements in order to dispose of resources even if there's an exception.