public async Task <StatusData> CheckFileStatus() { bool result = false; string outputStr = ""; StatusData resultData = new StatusData(); try { FileProtectionInfo protectionInfo = await FileProtectionManager.GetProtectionInfoAsync(m_FileHandle); if (protectionInfo.Status == FileProtectionStatus.Revoked) { outputStr += "\nFile " + m_FileHandle.Path + " is revoked"; } else { outputStr += "\nFile protection status of: " + m_FileHandle.Path + " is " + protectionInfo.Status; } if (protectionInfo.IsRoamable) { outputStr += "\nFile " + m_FileHandle.Path + " is roamable"; } else { outputStr += "\nFile " + m_FileHandle.Path + " is not roamable"; } result = true; } catch (Exception ex) { outputStr += "\n" + "Exception thrown:" + ex.ToString(); } resultData.result = result; resultData.outputStr = outputStr; return(resultData); }
private async void ProtectAsyncFileStatus_Click(object sender, RoutedEventArgs e) { if (m_FileHandle != null) { StatusData stData = await CheckFileStatus(); if (stData.result) { rootPage.NotifyUser(stData.outputStr, NotifyType.StatusMessage); } else { rootPage.NotifyUser(stData.outputStr, NotifyType.ErrorMessage); } } else { rootPage.NotifyUser("Please pick a file", NotifyType.ErrorMessage); } }