Total Pageviews

Monday, April 21, 2014

os.remove()

os.remove()
ប្រើសំរាប់លុបហ្វាល់ឬក៏ directory។ វាត្រឡប់ជាតំលៃដែលអាច
Result: true បើសិនជាហ្វាល់ត្រូវបានលុបចេញ (boolean)
Reason: nil បើសិនជាលុបចេញបានសំរេច ឬក៏ string ដែលនិយាយអំពីហេតុផលមិនអាច

ចំណំាះ វាអាចលុបបានចំពោះហ្វាល់នៅក្នុង DocumentsDirectory & TemporaryDirectory ចំណែកហ្វាល់នៅក្នុង ResourceDirectory ប្រើសំរាប់អានទេ
Syntax: os.remove (file)
File (តំរូវការ) វាជា String ដែលជាឈ្មោះរបស់ហ្វាល់ ឬ Directory ដែលត្រូវលុប
ARG2(ជំរើស)
[TYPE][api.type.TYPE]. Short description goes here.

សូមមើលកូដះ
local destDir = system.DocumentsDirectory  -- where the file is stored
local results, reason = os.remove( system.pathForFile( "apple.txt", destDir  ) )
if results then
   print( "file removed" )
else
   print( "file does not exist", reason )
end
--> file does not exist    apple.txt: No such file or directory


No comments:

Post a Comment