Delete a file: Difference between revisions

Added Kotlin
(Added Kotlin)
Line 540:
console.log("Done!");
})</lang>
 
=={{header|Kotlin}}==
<lang scala>// version 1.0.6
 
/* testing on Windows 10 which needs administrative privileges
to delete files from the root */
import java.io.File
 
fun main(args: Array<String>) {
val paths = arrayOf("input.txt", "docs", "c:\\input.txt", "c:\\docs")
var f: File
for (path in paths) {
f = File(path)
if (f.delete())
println("$path successfully deleted")
else
println("$path could not be deleted")
}
}</lang>
 
{{out}}
<pre>
input.txt successfully deleted
docs successfully deleted
c:\input.txt successfully deleted
c:\docs successfully deleted
</pre>
Running program again after files have been deleted:
{{out}}
<pre>
input.txt could not be deleted
docs could not be deleted
c:\input.txt could not be deleted
c:\docs could not be deleted
</pre>
 
=={{header|LabVIEW}}==
9,485

edits