Click here to Skip to main content
15,882,152 members
Home / Discussions / C#
   

C#

 
AnswerRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan20-May-16 22:28
professionalAfzaal Ahmad Zeeshan20-May-16 22:28 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241120-May-16 23:36
Jaimesh.241120-May-16 23:36 
GeneralRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan21-May-16 1:22
professionalAfzaal Ahmad Zeeshan21-May-16 1:22 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241122-May-16 21:11
Jaimesh.241122-May-16 21:11 
AnswerRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan22-May-16 21:18
professionalAfzaal Ahmad Zeeshan22-May-16 21:18 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241122-May-16 21:21
Jaimesh.241122-May-16 21:21 
GeneralRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan22-May-16 21:35
professionalAfzaal Ahmad Zeeshan22-May-16 21:35 
QuestionHow to read XML with directory structure Pin
Member 244330620-May-16 11:28
Member 244330620-May-16 11:28 
I saw a simple example from microsoft "How to: Populate an XML Tree from the File System (C#)".

But I cant figure out how to reverse the XML to get a list of all files with full qualified path simular to "dir /s /b" would produce:

Tmp\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe<br />
Size: 4608<br />
Tmp\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe.manifest<br />
Size: 473<br />
Tmp\ConsoleApplication1\obj\Debug\TempPE\ConsoleApplication1.csproj.FileListAbsolute.txt<br />
Size: 322<br />
... and so on<br />


Can somone help with this?

Example from MSDN:

C#
class Program
{
    static XElement CreateFileSystemXmlTree(string source)
    {
        DirectoryInfo di = new DirectoryInfo(source);
        return new XElement("Dir",
            new XAttribute("Name", di.Name),
            from d in Directory.GetDirectories(source)
            select CreateFileSystemXmlTree(d),
            from fi in di.GetFiles()
            select new XElement("File",
                new XElement("Name", fi.Name),
                new XElement("Length", fi.Length)
            )
        );
    }

    static void Main(string[] args)
    {
        XElement fileSystemTree = CreateFileSystemXmlTree("C:/Tmp");
        Console.WriteLine(fileSystemTree);
        Console.WriteLine("------");
        long totalFileSize =
            (from f in fileSystemTree.Descendants("File")
             select (long)f.Element("Length")).Sum();
        Console.WriteLine("Total File Size:{0}", totalFileSize);
    }
}


XML
<Dir Name="Tmp">
  <Dir Name="ConsoleApplication1">
    <Dir Name="bin">
      <Dir Name="Debug">
        <File>
          <Name>ConsoleApplication1.exe</Name>
          <Length>4608</Length>
        </File>
        <File>
          <Name>ConsoleApplication1.pdb</Name>
          <Length>11776</Length>
        </File>
        <File>
          <Name>ConsoleApplication1.vshost.exe</Name>
          <Length>9568</Length>
        </File>
        <File>
          <Name>ConsoleApplication1.vshost.exe.manifest</Name>
          <Length>473</Length>
        </File>
      </Dir>
    </Dir>
    <Dir Name="obj">
      <Dir Name="Debug">
        <Dir Name="TempPE" />
        <File>
          <Name>ConsoleApplication1.csproj.FileListAbsolute.txt</Name>
          <Length>322</Length>
        </File>
        <File>
          <Name>ConsoleApplication1.exe</Name>
          <Length>4608</Length>
        </File>
        <File>
          <Name>ConsoleApplication1.pdb</Name>
          <Length>11776</Length>
        </File>
      </Dir>
    </Dir>
    <Dir Name="Properties">
      <File>
        <Name>AssemblyInfo.cs</Name>
        <Length>1454</Length>
      </File>
    </Dir>
    <File>
      <Name>ConsoleApplication1.csproj</Name>
      <Length>2546</Length>
    </File>
    <File>
      <Name>ConsoleApplication1.sln</Name>
      <Length>937</Length>
    </File>
    <File>
      <Name>ConsoleApplication1.suo</Name>
      <Length>10752</Length>
    </File>
    <File>
      <Name>Program.cs</Name>
      <Length>269</Length>
    </File>
  </Dir>
</Dir>
------
Total File Size:59089

AnswerRe: How to read XML with directory structure Pin
Karthik_Mahalingam21-May-16 22:46
professionalKarthik_Mahalingam21-May-16 22:46 
GeneralRe: How to read XML with directory structure Pin
Member 244330622-May-16 9:12
Member 244330622-May-16 9:12 
GeneralRe: How to read XML with directory structure Pin
Member 244330622-May-16 12:53
Member 244330622-May-16 12:53 
SuggestionRe: How to read XML with directory structure Pin
Richard Deeming23-May-16 1:44
mveRichard Deeming23-May-16 1:44 
GeneralRe: How to read XML with directory structure Pin
Member 244330623-May-16 13:46
Member 244330623-May-16 13:46 
QuestionIs there a source code download for this article? Pin
Member 1253641620-May-16 10:59
Member 1253641620-May-16 10:59 
AnswerRe: Is there a source code download for this article? Pin
Pete O'Hanlon20-May-16 11:21
mvePete O'Hanlon20-May-16 11:21 
GeneralRe: Is there a source code download for this article? Pin
Richard Deeming20-May-16 11:28
mveRichard Deeming20-May-16 11:28 
GeneralRe: Is there a source code download for this article? Pin
Member 1253641620-May-16 11:32
Member 1253641620-May-16 11:32 
AnswerRe: Is there a source code download for this article? Pin
Richard Deeming20-May-16 11:33
mveRichard Deeming20-May-16 11:33 
JokeRe: Is there a source code download for this article? Pin
Member 1253641620-May-16 20:01
Member 1253641620-May-16 20:01 
Questiondelete directory / folder recursive, by pass locked files Pin
jkirkerx20-May-16 10:53
professionaljkirkerx20-May-16 10:53 
AnswerRe: delete directory / folder recursive, by pass locked files Pin
Member 244330620-May-16 11:50
Member 244330620-May-16 11:50 
GeneralRe: delete directory / folder recursive, by pass locked files Pin
jkirkerx20-May-16 12:30
professionaljkirkerx20-May-16 12:30 
AnswerProblem 2, access the HKLM as Admin doesn't work Pin
jkirkerx20-May-16 12:36
professionaljkirkerx20-May-16 12:36 
GeneralRe: Problem 2, access the HKLM as Admin doesn't work Pin
Member 244330620-May-16 12:53
Member 244330620-May-16 12:53 
GeneralRe: Problem 2, access the HKLM as Admin doesn't work Pin
jkirkerx21-May-16 12:00
professionaljkirkerx21-May-16 12:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.