本文整理汇总了C#中Microsoft.Live.LiveConnectClient.DeleteAsync方法的典型用法代码示例。如果您正苦于以下问题:C# LiveConnectClient.DeleteAsync方法的具体用法?C# LiveConnectClient.DeleteAsync怎么用?C# LiveConnectClient.DeleteAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Live.LiveConnectClient
的用法示例。
在下文中一共展示了LiveConnectClient.DeleteAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunButton_Click
private async void RunButton_Click(object sender, RoutedEventArgs e)
{
try
{
// Validate parameters
string path = pathTextBox.Text;
string destination = destinationTextBox.Text;
string requestBody = requestBodyTextBox.Text;
var scope = (authScopesComboBox.SelectedValue as ComboBoxItem).Content as string;
var method = (methodsComboBox.SelectedValue as ComboBoxItem).Content as string;
// acquire auth permissions
var authClient = new LiveAuthClient();
var authResult = await authClient.LoginAsync(new string[] { scope });
if (authResult.Session == null)
{
throw new InvalidOperationException("You need to login and give permission to the app.");
}
var liveConnectClient = new LiveConnectClient(authResult.Session);
LiveOperationResult operationResult = null;
switch (method)
{
case "GET":
operationResult = await liveConnectClient.GetAsync(path);
break;
case "POST":
operationResult = await liveConnectClient.PostAsync(path, requestBody);
break;
case "PUT":
operationResult = await liveConnectClient.PutAsync(path, requestBody);
break;
case "DELETE":
operationResult = await liveConnectClient.DeleteAsync(path);
break;
case "COPY":
operationResult = await liveConnectClient.CopyAsync(path, destination);
break;
case "MOVE":
operationResult = await liveConnectClient.MoveAsync(path, destination);
break;
}
if (operationResult != null)
{
Log("Operation succeeded: \r\n" + operationResult.RawResult);
}
}
catch (Exception ex)
{
Log("Got error: " + ex.Message);
}
}
示例2: RenameLiveFolder
public async Task<Boolean> RenameLiveFolder(String OldName, String NewName)
{
try
{
LiveConnectClient uploadClient = new LiveConnectClient(meClient.Session);
LiveOperationResult result = await uploadClient.GetAsync("/me/skydrive/files");
dynamic files = result.Result;
List<object> data = (List<object>)files.data;
foreach (dynamic item in data)
{
if (item.name == OldName)
{
try
{
LoadProfile(NewName);
await uploadClient.CopyAsync(OldName, NewName);
await uploadClient.DeleteAsync(OldName);
return true;
}
catch (NullReferenceException)
{
return false;
}
catch (FileNotFoundException)
{
return false;
}
catch (ArgumentOutOfRangeException)
{
return false;
}
}
}
}
catch (NullReferenceException)
{
}
catch (LiveConnectException)
{
}
return false;
}
示例3: MenuDelte_Click
/// <summary>
/// ContextMenu delete button tergar MenuDelte_Click and delete the picture from sky drive
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void MenuDelte_Click(object sender, RoutedEventArgs e)
{
var Menu = sender as MenuItem;
SkydrivePhoto selectedFile = Menu.DataContext as SkydrivePhoto;
string msgDelPic = SkyPhoto.Resources.Resources.msgDelPic;
string msgDelPicTitel = SkyPhoto.Resources.Resources.msgDelPicTitle;
MessageBoxResult m = MessageBox.Show(msgDelPic + selectedFile.Title + "?", msgDelPicTitel, MessageBoxButton.OKCancel);
if (m == MessageBoxResult.OK)
{
LiveConnectClient client = new LiveConnectClient(App.Session);
LiveOperationResult result = await client.DeleteAsync(selectedFile.ID);
DeleteFile_Completed(selectedFile, result);
}
else
{
return;
}
}
示例4: MenuItem_Click
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
// Tag contains the bound ID of the associated ListBoxItem
string itemID = ((MenuItem)sender).Tag.ToString();
if (itemID != null)
{
this.progressIndicator = new ProgressIndicator();
ProgressIndicatorHelper.showProgressIndicator("Deleting...", this, this.progressIndicator);
LiveConnectClient client = new LiveConnectClient(App.Current.LiveSession);
client.DeleteCompleted +=
new EventHandler<LiveOperationCompletedEventArgs>(DeleteFileOrFolder_Completed);
// for now, only allow deletes of non-folders
if (itemID.Contains("folder") == false)
{
client.DeleteAsync(itemID);
}
else
{
MessageBox.Show("I can't let you delete a folder, sorry!");
ProgressIndicatorHelper.hideProgressIndicator(this.progressIndicator);
}
}
}
示例5: uploadClient_UploadCompleted
//Finish uploading the file to SkyDrive storage
void uploadClient_UploadCompleted(object sender, LiveOperationCompletedEventArgs e)
{
if (e.Error == null)
{
MessageBox.Show("'"+ fileName + "' have been successfully saved to the SkyDrive", "All Done!", MessageBoxButton.OK);
SystemTray.ProgressIndicator.IsVisible = false;
//Maring 'invisible' UI upload file section
((FrameworkElement)ContentPanel.Children[1]).Height = 0;
//Update SkyDrive data list
this.DownloadSkyDriveDataList();
}
else
{
if (e.Error.Message == "The resource could not be created. The resource '"
+ fileName + ".txt" + "' already exists.")
{
if (MessageBox.Show("File with this name is already exist in SkyDrive data storage\nDo you want to rewrite existing file?",
"Information", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
//If 'Rewrite existing file?' message box result == OK -> delete existing file
//and upload new
//At first it's needed to get existing file ID
if (this.SkyDriveFilesCollection != null)
{
SkyDriveFileInfo fi = this.SkyDriveFilesCollection.Where(f => f.Name ==
this.fileName).FirstOrDefault();
//Set SystemTray.ProgressIndicator
ProgressIndicator prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "File uploading...";
SystemTray.SetProgressIndicator(this, prog);
LiveConnectClient client = new LiveConnectClient(LiveSession);
client.DeleteCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_DeleteExistingCompleted);
client.DeleteAsync(fi.FileID);
}
}
else
{
//If 'Rewrite existing file?' message box result == Cancel -> stop uploading file.
//In this case user will be able to rename existing
SystemTray.ProgressIndicator.IsVisible = false;
}
}
else
{
MessageBox.Show("There is an error occur during file uploading: " + e.Error.Message, "Warning", MessageBoxButton.OK);
SystemTray.ProgressIndicator.IsVisible = false;
}
}
}
示例6: DeleteMenu_Click
private void DeleteMenu_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show("Are you sure you want to delete this file?", "Delete", MessageBoxButton.OKCancel)
== MessageBoxResult.OK)
{
MenuItem menu = sender as MenuItem;
SkyDriveFileInfo info = menu.DataContext as SkyDriveFileInfo;
//Set SystemTray.ProgressIndicator
ProgressIndicator prog = new ProgressIndicator();
prog.IsIndeterminate = true;
prog.IsVisible = true;
prog.Text = "File deleting...";
SystemTray.SetProgressIndicator(this, prog);
LiveConnectClient client = new LiveConnectClient(this.LiveSession);
client.DeleteCompleted += new EventHandler<LiveOperationCompletedEventArgs>(client_DeleteCompleted);
client.DeleteAsync(info.FileID);
}
}
示例7: MenuDelte_Click
/// <summary>
/// ContextMenu delete button tergar MenuDelte_Click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MenuDelte_Click(object sender, RoutedEventArgs e)
{
var Menu = sender as MenuItem;
SkydriveAlbum selectedAlbum = Menu.DataContext as SkydriveAlbum;
string msgDel = SkyPhoto.Resources.Resources.msgDelAlbum;
string msgDelAlbumTitel = SkyPhoto.Resources.Resources.msgDelAlbumTitel;
MessageBoxResult m = MessageBox.Show(msgDel + selectedAlbum.Title + "?", msgDelAlbumTitel, MessageBoxButton.OKCancel);
if (m == MessageBoxResult.OK)
{
LiveConnectClient client = new LiveConnectClient(App.Session);
client.DeleteCompleted +=
new EventHandler<LiveOperationCompletedEventArgs>(DeleteFolder_Completed);
client.DeleteAsync(selectedAlbum.ID, selectedAlbum);
}
else
{
return;
}
}