cmd 창에서
nbtstat -A ***.***.***.***
위 명령어로 IP 주소로 컴퓨터이름을 얻어올 수 있다. 다만 netbios 기반으로 돌기 때문에 네트워크 단위를 넘어설 수 없다.
cmd 창에서
nbtstat -A ***.***.***.***
위 명령어로 IP 주소로 컴퓨터이름을 얻어올 수 있다. 다만 netbios 기반으로 돌기 때문에 네트워크 단위를 넘어설 수 없다.
FileStream fs = File.OpenRead(filePath); MemoryStream ms = new MemoryStream(); ms.SetLength(fs.Length); fs.Read(ms.GetBuffer(), 0, (int)ms.Length); fs.Close(); fs = File.OpenWrite(filePath + ".bak"); ms.WriteTo(fs); fs.Close(); ms.Close(); fs = null; ms = null;
<?xml version="1.0" encoding="utf-8" ?> <Persons> <Person name="John Smith"> <Age>30</Age> <Gender>Male</Gender> </Person> <Person name="Mike Folley"> <Age>25</Age> <Gender>Male</Gender> </Person> <Person name="Lisa Carter"> <Age>22</Age> <Gender>Female</Gender> </Person> <Person name="Jerry Frost"> <Age>27</Age> <Gender>Male</Gender> </Person> <Person name="Adam Wong"> <Age>35</Age> <Gender>Male</Gender> </Person> </Persons>
XPath Query |
Description |
. |
Selects the current node. |
.. |
Selects the parent of the current node. |
* |
Selects all the child of the current node. |
/ |
Selects the root nodes. |
// |
Selects nodes from the current node that match the selection expressions no matter where they are. |
//* |
Selects all elements in the document. |
/element |
Selects the root element named element. Staring a path with a / means you are using an absolute path to an element. |
/element/* |
Selects all the child of the root element. |
element/* |
Selects all the child nodes of a child element. |
element/child |
Selects the child elements which are a child of a sprecified child element of the current node. |
//element |
Selects all elements with the specified name regardless of where they are in the document. |
element/child |
Selects the child elements which are a child of a specified child element of the current node. |
//element |
Selects all elements with the specified name regardless if where they are in the document. |
element//child |
Selects all child elements of the parent regardless of where they are in the document. |
@attribute |
Selects an attribute of the current node where attribute is the name of the attribute. |
//@attribute |
Selects all the attributes specified by its name regardless of where they are in the document. |
@* |
Selects all attribute of the current node. |
element[i] |
Selects an element with the specified element name and the specified index. |
text() |
Selects the text of all the child nodes of the current element. |
//text() |
Selects text of every element in the document. |
//element/text() |
Selects the text of all the matching elements. |
//element[name='value'] |
Selects the text of all the matching elements. |
//elements[@att='value'] |
Selects all elements with the specified attribute having the specified value. |
FileStream fs = new FileStream("...경로", FileMode.Open, FileAccess.Read); XmlDocument xDoc = new XmlDocument(); xDoc.Load(fs); XmlNodeList xNodes = xDoc.SelectNodes("/Persons/Person"); // SelectNodes의 xPath 사용법을 알아둘 것!! if(xNodes[0] != null) // SelectNodes 후에는 선택해온 값이 있는지 확인부터 할것. { // 아닌 경우 NullReference 예외가 발생할 수 있음. // To do: string strTmp = xNodes[0].Attribute["name"].Value; } fs.Close(); fs = null;