import { Component , OnInit } from "@angular/core" ; import { knownFolders , path , File , Folder } from "@nativescript/core" ; @ Component ( { moduleId : module . id , templateUrl : "./update.component.html" } ) export class UpdateExampleComponent implements OnInit { public documents : Folder ; public file : File ; public myFolder : Folder ; public fileName : string = "TestFileName" ; public fileSuccessMessage : string ; public isItemVisible : boolean = false ; public folderName : string = "TestFolderName" ; public folderSuccessMessage : string ; public isFolderItemVisible : boolean = false ; ngOnInit ( ) { this . documents = knownFolders . documents ( ) ; this . file = this . documents . getFile ( "TestFileName.txt" ) ; this . myFolder = this . documents . getFolder ( "TestFolderName" ) ; } public onFileRename ( ) { this . file . rename ( this . fileName + ".txt" ) . then ( res => { this . fileSuccessMessage = "File renamed to: " + this . fileName + ".txt" ; this . isItemVisible = true ; } ) . catch ( err => { } ) ; } public onFolderRename ( ) { this . myFolder . rename ( this . folderName ) . then ( res => { this . folderSuccessMessage = "Folder renamed to: " + this . folderName ; this . isFolderItemVisible = true ; } ) . catch ( err => { } ) ; } }