How to create and save an XML file containing complete hierarchy of files and folders for a specified folder?

后端 未结 2 932
离开以前
离开以前 2020-12-22 15:37

this is my first post here on the site :)

So basically I need a gui application that can create and save XML file containing complete hierarchy of files and folders

2条回答
  •  一生所求
    2020-12-22 16:15

    Your question is - can u do my application for me - but anyway.

    I will give you some hints to get started with your Project.

    First of all - Check out MVVM here. This will help you - to handle WPF.

    1. Pick the starting folder

    Then you will need a FolderPicker to start your Search

      public static string PickFolder()
        {
            var dialog = new System.Windows.Forms.FolderBrowserDialog();
            System.Windows.Forms.DialogResult result = dialog.ShowDialog();
    
            string folder = string.Empty;
            switch (result)
            {
                case System.Windows.Forms.DialogResult.OK: return dialog.SelectedPath;
                case System.Windows.Forms.DialogResult.Cancel: return string.Empty;
                default: return string.Empty;
            }
        }
    

    U will need the System.Windows.Forms Assembly for this. (Project -> Add reference -> Assembly)

    2. folders and files

    Then you want to itterate through all folders.

    Check out System.IO.Directory here

    3. file information

    Check out System.IO.File here - this will give you some file data and to get the file size check this out

提交回复
热议问题