Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
AnswerRe: Providing Passphrase for GPG encryption to the command prompt Pin
Richard MacCutchan23-May-16 21:29
mveRichard MacCutchan23-May-16 21:29 
QuestionCash Drawer And C# Pin
Zeyad Jalil22-May-16 6:26
professionalZeyad Jalil22-May-16 6:26 
AnswerRe: Cash Drawer And C# Pin
OriginalGriff22-May-16 6:37
mveOriginalGriff22-May-16 6:37 
GeneralRe: Cash Drawer And C# Pin
Zeyad Jalil22-May-16 6:47
professionalZeyad Jalil22-May-16 6:47 
GeneralRe: Cash Drawer And C# Pin
OriginalGriff22-May-16 7:40
mveOriginalGriff22-May-16 7:40 
AnswerRe: Cash Drawer And C# Pin
jkirkerx22-May-16 11:00
professionaljkirkerx22-May-16 11:00 
QuestionCertificate in TCPListnear Pin
Jaimesh.241120-May-16 21:11
Jaimesh.241120-May-16 21:11 
AnswerRe: Certificate in TCPListnear Pin
Garth J Lancaster20-May-16 21:26
professionalGarth J Lancaster20-May-16 21:26 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241120-May-16 21:38
Jaimesh.241120-May-16 21:38 
GeneralRe: Certificate in TCPListnear Pin
Garth J Lancaster20-May-16 21:47
professionalGarth J Lancaster20-May-16 21:47 
GeneralRe: Certificate in TCPListnear Pin
Jaimesh.241120-May-16 21:59
Jaimesh.241120-May-16 21:59 
GeneralRe: Certificate in TCPListnear Pin
Garth J Lancaster20-May-16 22:19
professionalGarth J Lancaster20-May-16 22:19 
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 

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.