Exemplo n.º 1
0
        private void Delete(string cloudFileName)
        {
            // Initializing service proxy
            var cloudProxy = new CloudServiceClient();

            try
            {
                if (cloudProxy.DeleteFile(cloudFileName))
                {
                    Log("File " + cloudFileName + " deleted");
                    _fileList.RemoveAt(fileListBox.SelectedIndex);
                    _bindingSource.ResetBindings(false);
                }
                else
                {
                    Log("Error deleting the file");
                }
            }
            catch (Exception exception)
            {
                Log(exception.Message);
            }
            finally
            {
                // Close service proxy
                cloudProxy.Close();
            }
        }
Exemplo n.º 2
0
        private void backgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            // Operation was cancelled
            if (e.Cancelled)
            {
                // If uploading delete file server-side
                if (_upload)
                {
                    // Initializing service proxy
                    var cloudProxy = new CloudServiceClient();

                    // Deleting file server-side
                    cloudProxy.DeleteFile(_cloudFileName);

                    // Closing service proxy
                    cloudProxy.Close();
                }
                // If downloading delete file locally
                else
                {
                    if (File.Exists(_localFilePath))
                    {
                        File.Delete(_localFilePath);
                    }
                }
            }
            // Error
            else if (e.Error != null)
            {
                Close();
                MessageBox.Show("There has been an error in the process: " + e.Error.Message,
                                "Error", MessageBoxButtons.OK);
            }
            // Operation completed
            else
            {
                // Close form when work completes
                Close();
            }
        }