Dir

'获取收银机目录下的文件
    Public Shared Function GetDirFile(ByVal dir As StringAs String
        
Dim MyPath As String = ""
        
Dim MyName As String = ""
        
Dim FileName As String = ""
        
Try
            MyPath 
= Path.Combine(DL_PACK_PATH, dir)
            MyName 
= Microsoft.VisualBasic.Dir(Path.Combine(MyPath, "*.*"), Microsoft.VisualBasic.FileAttribute.Normal)
            
Do While MyName <> ""
                
If (GetAttr(Path.Combine(MyPath, MyName)) And FileAttribute.Normal) = FileAttribute.Normal Then
                    FileName 
= FileName & MyName & ",  "
                
End If
                MyName 
= Microsoft.VisualBasic.Dir()
            
Loop
        
Catch ex As Exception
            WriteLog(
"GetDirFile 获取收银机目录下的文件出错:" & ex.Message)
        
End Try
        
Return FileName.Trim().TrimEnd(",")
    
End Function


    
'删除收银机目录下的所有文件
    Public Shared Function DeleteDirFile(ByVal dir As StringAs Boolean
        
Dim MyPath As String = ""
        
Dim MyName As String = ""
        
Dim FileName As String = ""
        
Try
            MyPath 
= Path.Combine(DL_PACK_PATH, dir)
            MyName 
= Microsoft.VisualBasic.Dir(Path.Combine(MyPath, "*.*"), Microsoft.VisualBasic.FileAttribute.Normal)
            
Do While MyName <> ""
                
If (GetAttr(Path.Combine(MyPath, MyName)) And FileAttribute.Normal) = FileAttribute.Normal Then
                    My.Computer.FileSystem.DeleteFile(Path.Combine(MyPath, MyName))
                
End If
                MyName 
= Microsoft.VisualBasic.Dir()
            
Loop
            
Return True
        
Catch ex As Exception
            WriteLog(
"DeleteDirFile 删除收银机目录下的文件出错:" & ex.Message)
            
Return False
        
End Try

    
End Function
posted @ 2007-09-26 22:17  yongwnet  阅读(351)  评论(0编辑  收藏  举报