码迷,mamicode.com
首页 > 移动开发 > 详细

Basic4Android中按日期排序文件

时间:2014-07-16 23:11:55      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:android   des   blog   http   os   文件   

#Region  Project Attributes 
	#ApplicationLabel: SortByDateFileTest 
	#VersionCode: 20140627
	#VersionName: 
	‘SupportedOrientations possible values: unspecified, landscape or portrait.
	#SupportedOrientations: unspecified
	#CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	‘These global variables will be declared once when the application starts.
	‘These variables can be accessed from all modules.
	Type FileAndTime(Name As String, Time As Long)

End Sub

Sub Globals
	‘These global variables will be redeclared each time the activity is created.
	‘These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
	‘Do not forget to load the layout file created with the visual designer. For example:
	‘Activity.LoadLayout("Layout1")
   Dim files As List
   files = ListFilesByDate(File.DirRootExternal)
   Log(files.Size -1) ‘ 返回-1表示目录为空
   For i = 0 To files.Size - 1
      Dim fs As FileAndTime
      fs = files.Get(i)
      Log(fs.Name & ": " & DateTime.Date(fs.Time))
   Next

	
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ListFilesByDate(Folder As String) As List
   Dim files As List
   files = File.ListFiles(Folder) ‘ File.ListFiles 返回指定文件夹内所有目录和文件列表
   Dim sortedFiles As List
   sortedFiles.Initialize
   For i = 0 To files.Size - 1 ‘ List.Size 返回列表中的条目的数量
      Dim fs As FileAndTime
      fs.Name = files.Get(i) ‘ List.Get 返回List中第i项
      fs.Time = File.LastModified(Folder, fs.Name) ‘ File.LastModified 返回指定的文件的最后修改日期
      sortedFiles.Add(fs)
   Next
   sortedFiles.SortType("Time", False) ‘ List.SortType 将List按类型进行排序,Ture=升序,False=降序
   Return sortedFiles
End Sub

bubuko.com,布布扣

Basic4Android中按日期排序文件,布布扣,bubuko.com

Basic4Android中按日期排序文件

标签:android   des   blog   http   os   文件   

原文地址:http://www.cnblogs.com/moodsky/p/3811644.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!