file_basic_samples_4.py 1.4 KB

1234567891011121314151617181920212223242526272829
  1. def file_delete_samples(self, sharename, filename, service):
  2. print('\nDeleting all samples created for this demonstration.')
  3. try:
  4. # Deleting file: 'sharename/mydirectory/filename'
  5. # This is for demo purposes only, it's unnecessary, as we're deleting the share later
  6. print('Deleting a sample file.')
  7. share_client = service.get_share_client(sharename)
  8. directory_client = share_client.get_directory_client('mydirectory')
  9. directory_client.delete_file(file_name=filename)
  10. print('Sample file "' + filename + '" deleted from: ' + sharename + '/mydirectory' )
  11. # Deleting directory: 'sharename/mydirectory'
  12. print('Deleting sample directory and all files and directories under it.')
  13. share_client.delete_directory('mydirectory')
  14. print('Sample directory "/mydirectory" deleted from: ' + sharename)
  15. # Deleting share: 'sharename'
  16. print('Deleting sample share ' + sharename + ' and all files and directories under it.')
  17. share_client.delete_share(sharename)
  18. print('Sample share "' + sharename + '" deleted.')
  19. print('\nCompleted successfully - Azure Files samples deleted.')
  20. except Exception as e:
  21. print('********ErrorDelete***********')
  22. print(e)