Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. private const string folderLocation = @"D:";
  2. static void Main(string[] args)
  3. {
  4. DirectoryInfo dir = new DirectoryInfo(folderLocation);
  5. var doc = new XDocument(CREATEXML(dir));
  6. Console.WriteLine(doc.ToString());
  7. Console.Read();
  8.  
  9. }
  10.  
  11. private static XElement CREATEXML(DirectoryInfo dir)
  12. {
  13. //za sve direktorijume
  14. var xmlInfo = new XElement("serverfiles", new XAttribute("name", dir.Name));
  15.  
  16.  
  17. //za sve fajlove
  18. foreach (var file in dir.GetFiles())
  19. {
  20.  
  21. xmlInfo.Add(new XElement("file", new XAttribute("name", file.Name)));
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement