c#

swb·2022년 5월 23일
1

1. 파일 내에서 특정 문자열을 찾아 변경하기

(1)

string str = File.ReadAllText(FilePath);
str = str.Replace("origin string", "replace string");
File.WriteAllText(FilePath, str);

(2)

XDocument document;
using (FileStream xmlFile = File.OpenRead(FilePath))
{
    document = XDocument.Load(xmlFile);
    
    var element = txtValue.Tag as XElement;
    element.Value = txtValue.Text;
    
    document.Save(FilePath);
}

2. xml treeview

(1) XElement

element.Value = xml의 모든 값들을 의미
element.Name.ToString() = element의 name을 의미
element.Attributes().ElementsAt(index).ToString() = element의 attribute 값

3. 리스트 중복제거

(1)

list = list.Distinct().ToList();
profile
개발 시작

0개의 댓글