VB.net比较远程文件

时间:2014-09-27 04:23:07

标签: vb.net

嗨,大家好我正在尝试构建i文件更新程序。目前我有它所以它下载和解压缩它们很好,但我遇到的问题是当我使用文件比较功能来查看远程文件是否更新它提供错误URI不支持。所以我做了一些研究,并得出结论,不支持远程文件检查。如果有人尝试过这样的专长,或者有任何建议,那么这就是我的文件比较代码:

    Try
        'Check if the file resides on Local location
        If IO.File.Exists(DestinationFile) Then
            MsgBox("Found File")
            'File exist locally. Now checking if it’s modified
            If Not (IO.File.GetLastWriteTime(DestinationFile).Equals(IO.File.GetLastWriteTime(SourceFile))) Then
                MsgBox("File is out of date")
                'File is modified. So copy the file from  server to local
                IO.File.Copy(SourceFile, DestinationFile, True)
                FileCompare2 = FileCopyStatus.ModifiedFileCopied
            Else
                'If no change just set the copy status
                MsgBox("file is current")
                FileCompare2 = FileCopyStatus.Nochange
            End If
        Else
            'File doesn’t exist locally so copy the file from server
            MsgBox("file not found")
            IO.File.Copy(SourceFile, DestinationFile, True)
            FileCompare2 = FileCopyStatus.NewFileCopied
        End If
    Catch fileErr As IO.FileNotFoundException
        'Always catch exception at the highest level of the application 
        Throw New Exception("File not found:" + fileErr.Message)
    Catch IOErr As IO.IOException
        Throw
    End Try

0 个答案:

没有答案