pauledwardian
asked on
C# Replace specific line number
How can I use this method to receive an integer index number and then replaces the string in that particular line:
public void replace (int index)
{
try
{
String strFile = File.ReadAllText("c:\\test.txt");
if (strFile.Contains("A"))
{
strFile = strFile.Replace("P", "A");
strFile = strFile.Replace(" ", ";");
File.WriteAllLines("c:\\test.txt", strFile[index]);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fantastic!
Open in new window