pathRainfallFile this is a file path
_strTxtSavingLocation = _pathRainfallFolder + "stations.txt";
public void StationsEntryOnNotepad(DataTable dtData, string pathRainfallFile)
{
string fullRailfallPathFile = string.Empty;
if (dtData != null && dtData.Rows.Count > 0)
{
fullRailfallPathFile = Path.Combine(pathRainfallFile);
FileStream fsRainfall = new FileStream(fullRailfallPathFile, FileMode.Create, FileAccess.Write);
StreamWriter swRainfall = new StreamWriter(fsRainfall, Encoding.UTF8);
for (int iRowCount = 0; iRowCount < dtData.Rows.Count; iRowCount++)
{
StringBuilder sbStationDataEntry = new StringBuilder();
for (int iColCount = 0; iColCount < dtData.Columns.Count; iColCount++)
{
sbStationDataEntry.Append(Convert.ToString(dtData.Rows[iRowCount][iColCount]));
if (iColCount < dtData.Columns.Count - 1)
{
switch (iColCount)
{
case 0: { sbStationDataEntry.Append(' ', 8); break; }
case 1: { sbStationDataEntry.Append(' ', 20); break; }
case 2: { sbStationDataEntry.Append(' ', 1); break; }
case 3: { sbStationDataEntry.Append(' ', 1); break; }
case 4: { sbStationDataEntry.Append(' ', 0); break; }
}
}
}
swRainfall.WriteLine(sbStationDataEntry.ToString());
}
swRainfall.Flush();
swRainfall.Close();
fsRainfall.Dispose();
}
_strTxtSavingLocation = _pathRainfallFolder + "stations.txt";
public void StationsEntryOnNotepad(DataTable dtData, string pathRainfallFile)
{
string fullRailfallPathFile = string.Empty;
if (dtData != null && dtData.Rows.Count > 0)
{
fullRailfallPathFile = Path.Combine(pathRainfallFile);
FileStream fsRainfall = new FileStream(fullRailfallPathFile, FileMode.Create, FileAccess.Write);
StreamWriter swRainfall = new StreamWriter(fsRainfall, Encoding.UTF8);
for (int iRowCount = 0; iRowCount < dtData.Rows.Count; iRowCount++)
{
StringBuilder sbStationDataEntry = new StringBuilder();
for (int iColCount = 0; iColCount < dtData.Columns.Count; iColCount++)
{
sbStationDataEntry.Append(Convert.ToString(dtData.Rows[iRowCount][iColCount]));
if (iColCount < dtData.Columns.Count - 1)
{
switch (iColCount)
{
case 0: { sbStationDataEntry.Append(' ', 8); break; }
case 1: { sbStationDataEntry.Append(' ', 20); break; }
case 2: { sbStationDataEntry.Append(' ', 1); break; }
case 3: { sbStationDataEntry.Append(' ', 1); break; }
case 4: { sbStationDataEntry.Append(' ', 0); break; }
}
}
}
swRainfall.WriteLine(sbStationDataEntry.ToString());
}
swRainfall.Flush();
swRainfall.Close();
fsRainfall.Dispose();
}
No comments:
Post a Comment