/// <summary>
        /// Retrieve files from the selected SPOSite and create a csv
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGetTargetFiles_Click(object sender, RoutedEventArgs e)
        {
            //We retrieve the selected list from the Treeview and related SPOSite
            string[] selection = getSelectedTreeview();

            //We instanciate the SPOLogic class
            SPOLogic spol = new SPOLogic(credential, selection[1]);

            //We retrieve the site Title
            string siteUrl  = selection[1];
            string siteName = siteUrl.Remove(0, (siteUrl.LastIndexOf("/")));

            //We retrieve the library Title
            var    list     = spol.getListName(selection[0]);
            string listName = list.RootFolder.Name.ToString();

            //We create the Site/Library Url to compute the Normalized path
            string siteLibUrl = string.Format("/sites{0}/{1}", siteName, listName);



            //We retrieve listitems from the selected library
            ListItemCollection listItems = spol.getLibraryFile(selection[0]);

            //We create the path of the csv file
            DateTime now         = DateTime.Now;
            var      date        = now.ToString("yyyy-MM-dd-HH-mm-ss");
            string   csvFileName = "GetListItem";
            var      appPath     = AppDomain.CurrentDomain.BaseDirectory;
            var      csvfilePath = $"{appPath}{csvFileName}{date}.csv";
            //We create the stringbuilder
            var csv    = new StringBuilder();
            var header = "Filepath,FileName,NormalizedPath,Hash";

            csv.AppendLine(header);

            //We loop the listitems to populate the csv
            foreach (ListItem listItem in listItems)
            {
                if (listItem.FileSystemObjectType == FileSystemObjectType.Folder)
                {
                    continue;
                }
                string filePath       = listItem.FieldValues["FileRef"].ToString();
                string normalizedPath = filePath.Replace(siteLibUrl, "");

                string fileActualPath = $"{selection[1]}/{selection[0]}/{listItem.FieldValues["FileLeafRef"]}";

                listItem.

                Logic.FileHash HashObj = new Logic.FileHash(fileActualPath);
                string         hash    = HashObj.CreateHash();

                var newLine = string.Format("{0},{1},{2},{3}", listItem.FieldValues["FileRef"], listItem.FieldValues["FileLeafRef"], normalizedPath, hash);
                csv.AppendLine(newLine);
            }

            System.IO.File.WriteAllText(csvfilePath, csv.ToString(), Encoding.UTF8);
            MessageBox.Show("Task done");
        }
        /// <summary>
        /// Expand SPOSite in the treeview to show non hidden lists
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Folder_Expanded(object sender, RoutedEventArgs e)
        {
            //We declare the sender TreeViewItem
            var item = (TreeViewItem)sender;

            // If the item only contains the dumy data
            if (item.Items.Count != 1 || item.Items == null)
            {
                return;
            }
            //Clear dummy item
            item.Items.Clear();

            // Get Site library
            var SitePath = (string)item.Tag;

            // We populate TreeViewItems using Threading
            Task.Factory.StartNew(() =>
            {
                // Call the SPOLogic object and pass the item.Url
                var sp = new SPOLogic(credential, SitePath);
                // We call for this site Lists and filter hidden Lists
                IEnumerable <Microsoft.SharePoint.Client.List> lists = sp.getWebLists().Where(l => !l.Hidden);

                item.Dispatcher.Invoke(() =>
                {
                    // We push TreeViewIems from lists
                    foreach (var list in lists)
                    {
                        var subitem = new TreeViewItem
                        {
                            Header = list.Title + " (" + list.ItemCount + ") - " + list.BaseTemplate.ToString(),
                            Tag    = list.BaseTemplate.ToString(),
                        };
                        item.Items.Add(subitem);
                    }
                });
            });// End Task
        }
        /// <summary>
        /// Popullate treeview with SPOSite
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Call the SPOLogic object
            SPOLogic sp = new SPOLogic(credential, tenantUrl);

            // Ask for Sites and loop
            SPOSitePropertiesEnumerable Tenant = sp.getTenantProp();

            foreach (var site in Tenant)
            {
                var item = new TreeViewItem
                {
                    Header = site.Url,
                    Tag    = site.Url,
                };
                // Adding dumy item.items for expand icon to show
                item.Items.Add(null);
                // Listen out for item being expanded
                item.Expanded += Folder_Expanded;
                SiteView.Items.Add(item);
            }
        }