Click here to Skip to main content
15,125,968 members
Home / Discussions / C#
   

C#

 
AnswerRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan20-May-16 23:28
mveAfzaal Ahmad Zeeshan20-May-16 23:28 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241121-May-16 0:36
MemberJaimesh.241121-May-16 0:36 
GeneralRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan21-May-16 2:22
mveAfzaal Ahmad Zeeshan21-May-16 2:22 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241122-May-16 22:11
MemberJaimesh.241122-May-16 22:11 
AnswerRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan22-May-16 22:18
mveAfzaal Ahmad Zeeshan22-May-16 22:18 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241122-May-16 22:21
MemberJaimesh.241122-May-16 22:21 
GeneralRe: Certificate in TCPListnear Pin
Afzaal Ahmad Zeeshan22-May-16 22:35
mveAfzaal Ahmad Zeeshan22-May-16 22:35 
QuestionHow to read XML with directory structure Pin
Member 244330620-May-16 12:28
MemberMember 244330620-May-16 12: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 23:46
professionalKarthik_Mahalingam21-May-16 23:46 
GeneralRe: How to read XML with directory structure Pin
Member 244330622-May-16 10:12
MemberMember 244330622-May-16 10:12 
GeneralRe: How to read XML with directory structure Pin
Member 244330622-May-16 13:53
MemberMember 244330622-May-16 13:53 
SuggestionRe: How to read XML with directory structure Pin
Richard Deeming23-May-16 2:44
mveRichard Deeming23-May-16 2:44 
GeneralRe: How to read XML with directory structure Pin
Member 244330623-May-16 14:46
MemberMember 244330623-May-16 14:46 
QuestionIs there a source code download for this article? Pin
Member 1253641620-May-16 11:59
MemberMember 1253641620-May-16 11:59 
AnswerRe: Is there a source code download for this article? Pin
Pete O'Hanlon20-May-16 12:21
mvePete O'Hanlon20-May-16 12:21 
GeneralRe: Is there a source code download for this article? Pin
Richard Deeming20-May-16 12:28
mveRichard Deeming20-May-16 12:28 
GeneralRe: Is there a source code download for this article? Pin
Member 1253641620-May-16 12:32
MemberMember 1253641620-May-16 12:32 
AnswerRe: Is there a source code download for this article? Pin
Richard Deeming20-May-16 12:33
mveRichard Deeming20-May-16 12:33 
JokeRe: Is there a source code download for this article? Pin
Member 1253641620-May-16 21:01
MemberMember 1253641620-May-16 21:01 
Questiondelete directory / folder recursive, by pass locked files Pin
jkirkerx20-May-16 11:53
professionaljkirkerx20-May-16 11:53 
AnswerRe: delete directory / folder recursive, by pass locked files Pin
Member 244330620-May-16 12:50
MemberMember 244330620-May-16 12:50 
GeneralRe: delete directory / folder recursive, by pass locked files Pin
jkirkerx20-May-16 13:30
professionaljkirkerx20-May-16 13:30 
AnswerProblem 2, access the HKLM as Admin doesn't work Pin
jkirkerx20-May-16 13:36
professionaljkirkerx20-May-16 13:36 
GeneralRe: Problem 2, access the HKLM as Admin doesn't work Pin
Member 244330620-May-16 13:53
MemberMember 244330620-May-16 13:53 
GeneralRe: Problem 2, access the HKLM as Admin doesn't work Pin
jkirkerx21-May-16 13:00
professionaljkirkerx21-May-16 13: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.