import { Component } from "@angular/core" ; import { File , Folder , knownFolders } from "@nativescript/core" ; @ Component ( { moduleId : module . id , templateUrl : "./delete.component.html" } ) export class DeleteExampleComponent { public documents : Folder ; public file : File ; public myFolder : Folder ; public resultMessage : string = "" ; constructor ( ) { this . documents = knownFolders . documents ( ) ; this . myFolder = this . documents . getFolder ( "TestFolderName" ) ; this . file = this . myFolder . getFile ( "TestFileName.txt" ) ; } public onDeleteFile ( ) { if ( this . file ) { this . file . remove ( ) . then ( res => { this . resultMessage = "File successfully deleted!" ; } ) . catch ( err => { console . log ( err . stack ) ; } ) ; } else { this . resultMessage = "Already deleted file!" ; } } public onDeleteFolder ( ) { if ( this . myFolder ) { this . myFolder . remove ( ) . then ( fres => { this . resultMessage = "Folder successfully deleted!" ; } ) . catch ( err => { console . log ( err . stack ) ; } ) ; } else { this . resultMessage = "Already deleted folder!" ; } } public onClearFolder ( ) { if ( this . myFolder ) { this . myFolder . clear ( ) . then ( res => { this . resultMessage = "Folder successfully cleared!" ; } ) . catch ( err => { console . log ( err . stack ) ; } ) ; } else { this . resultMessage = "Cannot clear already deleted folder" ; } } public onReset ( ) { this . documents = knownFolders . documents ( ) ; this . myFolder = this . documents . getFolder ( "TestFolderName" ) ; this . file = this . myFolder . getFile ( "TestFileName.txt" ) ; this . resultMessage = "Successfully reset!" ; } }