-1

我有一个基于 Web 的应用程序,我需要添加新功能是将 PDF 文件从 DVD 上传到服务器中的文件夹位置。

像这样的 DVD 结构 1- 文件夹 12072013 2- 在同一级别有 CSV 文件和名为图像的文件夹。

我需要上传完成的CSV文件中的数据,我还需要上传Images文件夹中的PDF文件,将其从DVD复制到服务器中的文件夹。

4

1 回答 1

0
Sub CopyDirectory(ByVal SourcePath As String, ByVal DestPath As String, Optional ByVal Overwrite As Boolean = True)
    Application.DoEvents()
    Dim SourceDir As DirectoryInfo = New DirectoryInfo(SourcePath)
    Dim DestDir As DirectoryInfo = New DirectoryInfo(DestPath)

    ' the source directory must exist, otherwise throw an exception
    If SourceDir.Exists Then
        ' if destination SubDir's parent SubDir does not exist throw an exception
        If Not DestDir.Parent.Exists Then
            Throw New DirectoryNotFoundException _
                ("Destination directory does not exist: " + DestDir.Parent.FullName)
        End If

        If Not DestDir.Exists Then
            DestDir.Create()
        End If

        ' copy all the files of the current directory
        Dim ChildFile As FileInfo
        For Each ChildFile In SourceDir.GetFiles()
            If Overwrite Then
                ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), True)
            Else
                If Not File.Exists(Path.Combine(DestDir.FullName, ChildFile.Name)) Then
                    ChildFile.CopyTo(Path.Combine(DestDir.FullName, ChildFile.Name), False)
                End If
            End If
        Next

        ' copy all the sub-directories by5 recursively calling this same routine
        Dim SubDir As DirectoryInfo
        For Each SubDir In SourceDir.GetDirectories()
            CopyDirectory(SubDir.FullName, Path.Combine(DestDir.FullName, _
                SubDir.Name), Overwrite)
        Next
    Else
        Throw New DirectoryNotFoundException("Source directory does not exist: " + SourceDir.FullName)
    End If
End Sub
于 2013-09-08T15:11:09.643 回答