프로그래밍/C#
[C#] 파일 특정라인 변경하는 함수
자바조아!
2019. 1. 4. 23:58
1. 함수
static void LineChanger(string newText, string fileName, int line_to_edit)
{
string[] arrLine = File.ReadAllLines(fileName, Encoding.Default);
arrLine[line_to_edit - 1] = newText;
File.WriteAllLines(fileName, arrLine, Encoding.Default);
}
2. 사용방법
// 데이터저장
LineChanger(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", authVO.username, authVO.password, authVO.company, authVO.url, authVO.apiKey, authVO.secretKey), "./config/auth.txt", globalIndex++);