public void MBasinASCIIEntryOnNotepad(DataTable dtData, string strPathASCIIFile, string stationName)
{
string fullASCIIFile = string.Empty;
if (dtData != null && dtData.Rows.Count > 0)
{
if (!Directory.Exists(_strAsciiFolder))
{
Directory.CreateDirectory(_strAsciiFolder);
}
fullASCIIFile = Path.Combine(strPathASCIIFile);
FileStream fsASCII = new FileStream(fullASCIIFile, FileMode.Create, FileAccess.Write);
StreamWriter swASCII = new StreamWriter(fsASCII, Encoding.UTF8);
for (int iRowCount = 0; iRowCount < dtData.Rows.Count; iRowCount++)
{
StringBuilder sbASCIIDataEntry = new StringBuilder();
for (int iColCount = 0; iColCount < dtData.Columns.Count; iColCount++)
{
sbASCIIDataEntry.Append(Convert.ToString(dtData.Rows[iRowCount][iColCount]));
if (iColCount < dtData.Columns.Count - 1)
{
sbASCIIDataEntry.Append("\t");
}
}
swASCII.WriteLine(sbASCIIDataEntry.ToString());
}
swASCII.Flush();
swASCII.Close();
swASCII.Dispose();
}
}
{
string fullASCIIFile = string.Empty;
if (dtData != null && dtData.Rows.Count > 0)
{
if (!Directory.Exists(_strAsciiFolder))
{
Directory.CreateDirectory(_strAsciiFolder);
}
fullASCIIFile = Path.Combine(strPathASCIIFile);
FileStream fsASCII = new FileStream(fullASCIIFile, FileMode.Create, FileAccess.Write);
StreamWriter swASCII = new StreamWriter(fsASCII, Encoding.UTF8);
for (int iRowCount = 0; iRowCount < dtData.Rows.Count; iRowCount++)
{
StringBuilder sbASCIIDataEntry = new StringBuilder();
for (int iColCount = 0; iColCount < dtData.Columns.Count; iColCount++)
{
sbASCIIDataEntry.Append(Convert.ToString(dtData.Rows[iRowCount][iColCount]));
if (iColCount < dtData.Columns.Count - 1)
{
sbASCIIDataEntry.Append("\t");
}
}
swASCII.WriteLine(sbASCIIDataEntry.ToString());
}
swASCII.Flush();
swASCII.Close();
swASCII.Dispose();
}
}
No comments:
Post a Comment