Saturday, 23 April 2011

C# File Stream read/wirte

More File Stream Samples
//******************

FileStream file = File.OpenRead("c:\\siraj\\Post_Check\\" + icb_inputfile);
byte[] buffer = new byte[81];

int c = file.Read(buffer, 0, buffer.Length);
while (c > 0)
{
TXTLine = System.Text.ASCIIEncoding.ASCII.GetString(buffer);

switch (TXTLine.Substring(TXTLine.Length - 3, 2))
{
case "SR":
case "PP":
break;
}
c = file.Read(buffer, 0, buffer.Length);
}

file.Close();

//**********************
//Write Ascii Files
strIssuerFileName = "c:\\Siraj\\" + strIssuerFileName;
StreamWriter sw = new StreamWriter(strIssuerFileName);
sw.Write(strFileText.ToString());
sw.Close();

No comments:

Post a Comment