1234567891011121314151617181920212223242526272829 |
- def file_delete_samples(self, sharename, filename, service):
- print('\nDeleting all samples created for this demonstration.')
- try:
- # Deleting file: 'sharename/mydirectory/filename'
- # This is for demo purposes only, it's unnecessary, as we're deleting the share later
- print('Deleting a sample file.')
- share_client = service.get_share_client(sharename)
- directory_client = share_client.get_directory_client('mydirectory')
-
- directory_client.delete_file(file_name=filename)
- print('Sample file "' + filename + '" deleted from: ' + sharename + '/mydirectory' )
- # Deleting directory: 'sharename/mydirectory'
- print('Deleting sample directory and all files and directories under it.')
- share_client.delete_directory('mydirectory')
- print('Sample directory "/mydirectory" deleted from: ' + sharename)
- # Deleting share: 'sharename'
- print('Deleting sample share ' + sharename + ' and all files and directories under it.')
- share_client.delete_share(sharename)
- print('Sample share "' + sharename + '" deleted.')
- print('\nCompleted successfully - Azure Files samples deleted.')
- except Exception as e:
- print('********ErrorDelete***********')
- print(e)
|