private async Task LoadFilesAndFoldersAsync()
        {
            LoggingViewModel.Instance.Information = "Retrieving items ...";
            this.LoadingFilesAndFolders           = true;

            DirectoryItems.Clear();

            IEnumerable <IItem> files = await _fileOperations.GetMyFilesAsync();

            if (files != null)
            {
                foreach (IItem file in files)
                {
                    FileSystemItemViewModel _directoryItem = new FileSystemItemViewModel(file);

                    //Adding FileSystemItems to observable collection.
                    DirectoryItems.Add(_directoryItem);
                }
                LoggingViewModel.Instance.Information = string.Empty;
            }
            else
            {
                LoggingViewModel.Instance.Information = "We couldn't get your file and folder list.";
            }

            this.LoadingFilesAndFolders = false;
        }
        /// <summary>
        /// Deletes the selected item or folder from the ListBox.
        /// </summary>
        /// <returns>A Boolean value that indicates whether the file or folder was successfully deleted.</returns>
        internal async Task<bool?> DeleteFileOrFolderAsync(FileSystemItemViewModel _selectedFileObject)
        {
            bool? isSuccess = false;

            try
            {
                // Gets the FileSystemItem that is selected in the bound ListBox control.
                IFileSystemItem fileOrFolderToDelete = _selectedFileObject.FileSystemItem;

                // This results in a call to the service.
                await fileOrFolderToDelete.DeleteAsync();

                isSuccess = true;
            }
            catch (Microsoft.Data.OData.ODataErrorException)
            {
                isSuccess = null;
            }
            catch (NullReferenceException)
            {
                isSuccess = null;
            }

            return isSuccess;
        }
        /// <summary>
        /// Command for getting the file and folder list.
        /// </summary>
        async void ExecuteGetFileAndFolderListCommandAsync()
        {
            DirectoryItems.Clear();

            IEnumerable <IFileSystemItem> files = await _fileOperations.GetMyFilesAsync();

            if (files != null)
            {
                foreach (IFileSystemItem file in files)
                {
                    FileSystemItemViewModel _directoryItem = new FileSystemItemViewModel(file);

                    //Adding FileSystemItems to observable collection.
                    DirectoryItems.Add(_directoryItem);
                }
            }
            else
            {
                LoggingViewModel.Instance.Information = "We couldn't get your file and folder list.";
            }
        }
        /// <summary>
        /// Downloads a file selected in the ListBox control.
        /// </summary>
        /// <param name="_selectedFileObject">The file selected in the ListBox.</param>
        /// <returns>A Stream of the downloaded file.</returns>
        internal async Task<Stream> DownloadFileAsync(FileSystemItemViewModel _selectedFileObject)
        {

            File file;
            Stream stream = null;

            try
            {
                // Get a handle on the selected item.
                IItem myFile = _selectedFileObject.FileSystemItem;
                file = myFile as File;
                // Download the file from the service. This results in call to the service.
                stream = await file.DownloadAsync();
            }

            catch (NullReferenceException)
            {
                // Silently fail. A null stream will be handled higher up the stack.
            }

            return stream;
        }
        /// <summary>
        /// Update the currently selected item by appending new text.
        /// </summary>
        /// <param name="_selectedFileObject">The file selected in the ListBox.</param>
        /// <param name="fileText">The updated text contents of the file.</param>
        /// <returns>A Boolean value that indicates whether the text file was successfully updated.</returns>
        internal async Task<bool> UpdateTextFileAsync(FileSystemItemViewModel _selectedFileObject, string fileText)
        {
            File file;
            byte[] byteArray;
            bool isSuccess = false;

            try
            {
                // Get a handle on the selected item.
                IItem myFile = _selectedFileObject.FileSystemItem;
                file = myFile as File;
                string updateTime = "\n\r\n\rLast update at " + DateTime.Now.ToLocalTime().ToString();
                byteArray = Encoding.UTF8.GetBytes(fileText + updateTime);

                using (MemoryStream stream = new MemoryStream(byteArray))
                {
                    // Update the file. This results in a call to the service.
                    await file.UploadAsync(stream);
                    isSuccess = true; // We've updated the file.
                }
            }
            catch (ArgumentException)
            {
                isSuccess = false;
            }

          return isSuccess; 
        }
        /// <summary>
        /// Reads the contents of a text file and displays the results in a TextBox.
        /// </summary>
        /// <param name="_selectedFileObject">The file selected in the ListBox.</param>
        /// <returns>A Boolean value that indicates whether the text file was successfully read.</returns>
        internal async Task<object[]> ReadTextFileAsync(FileSystemItemViewModel _selectedFileObject)
        {
            
            string fileContents = string.Empty;
            object[] results = new object[] { fileContents, false };

            try
            {
                // Get a handle on the selected item.
                IItem myFile = _selectedFileObject.FileSystemItem;

                // Check that the selected item is a text-based file.
                if (!myFile.Name.EndsWith(".txt") && !myFile.Name.EndsWith(".xml"))
                {
                    results[0] = string.Empty;
                    results[1] = false;
                    return results;
                }

                File file = myFile as File;

                // Download the file contents as a string. This results in a call to the service.
                using (Stream stream = await file.DownloadAsync())
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        results[0] = await reader.ReadToEndAsync();
                        results[1] = true;
                    }
                }
            }
            catch (NullReferenceException)
            {
                results[1] = false;
            }
            catch (ArgumentException)
            {
                results[1] = false;
            }

            return results;
        }
        private async Task LoadFilesAndFoldersAsync()
        {
            LoggingViewModel.Instance.Information = "Retrieving items ...";
            this.LoadingFilesAndFolders = true;

            DirectoryItems.Clear();

            IEnumerable<IItem> files = await _fileOperations.GetMyFilesAsync();

            if (files != null)
            {
                foreach (IItem file in files)
                {
                    FileSystemItemViewModel _directoryItem = new FileSystemItemViewModel(file);

                    //Adding FileSystemItems to observable collection.
                    DirectoryItems.Add(_directoryItem);
                }
                LoggingViewModel.Instance.Information = string.Empty;

            }
            else
            {
                LoggingViewModel.Instance.Information = "We couldn't get your file and folder list.";
            }

            this.LoadingFilesAndFolders = false;
        }
        /// <summary>
        /// Command for getting the file and folder list.
        /// </summary>
        async void ExecuteGetFileAndFolderListCommandAsync()
        {
            DirectoryItems.Clear();

            IEnumerable<IFileSystemItem> files = await _fileOperations.GetMyFilesAsync();

            if (files != null)
            {
                foreach (IFileSystemItem file in files)
                {
                    FileSystemItemViewModel _directoryItem = new FileSystemItemViewModel(file);

                    //Adding FileSystemItems to observable collection.
                    DirectoryItems.Add(_directoryItem);
                }

            }
            else
            {
                LoggingViewModel.Instance.Information = "We couldn't get your file and folder list.";
            }

            
        }