try
{
StringBuilder
obj1 = new StringBuilder();
string
sCon = string.Empty;
string
scon1 = string.Empty;
using
(StreamReader sr = new
StreamReader("file
path" + "file name"))
{
sCon = sr.ReadToEnd();
}
obj1.Append(sCon.Substring(0,
sCon.IndexOf("#spoint") + 11) + Environment.NewLine);
int
startpoint = sCon.IndexOf("#spoint")
+ 11;
int
endpoint = sCon.IndexOf("#epoint");
string
Test = sCon.Substring(startpoint, endpoint - startpoint);
if
(Test.IndexOf("line Name ") >
-1)
{
obj1.Append(Test);
}
obj1.Append("New string append" + Environment.NewLine);
obj1.Append(sCon.Substring(sCon.IndexOf("#epoint"))
+ Environment.NewLine);
scon2 = obj1.ToString();
FileStream
fsPattern = File.OpenWrite("file path" + "file
name");
Encoding
encPattern = Encoding.ASCII;
byte[]
restPattern = encPattern.GetBytes(obj1.ToString());
fsPattern.Write(restPattern, 0,
objPattern.Length);
fsPattern.Flush();
fsPattern.Close();
fsPattern.Dispose();
}
catch (Exception ex)
{
}
No comments:
Post a Comment