【问题标题】:Uploading PDF files to Server in VB.net将 PDF 文件上传到 VB.net 中的服务器
【发布时间】:2013-09-08 12:34:30
【问题描述】:

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

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

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

【问题讨论】:

  • 你的问题到底是什么?

标签: asp.net vb.net pdf file-upload web


【解决方案1】:
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

【讨论】:

    猜你喜欢
    • 2011-08-17
    • 2018-07-11
    • 2019-05-16
    • 1970-01-01
    • 2020-01-30
    • 1970-01-01
    • 2020-04-18
    • 2011-10-06
    • 1970-01-01
    相关资源
    最近更新 更多