2013-09-08 4 views
-1

У меня есть веб-приложение. Мне нужно добавить новый featuer для загрузки файлов PDF с DVD в папку на сервере.Загрузка файлов PDF на сервер в VB.net

DVD структурированный как это 1- Папка 12072013 2- на том же уровне есть CSV-файл и папка, называемые изображениями.

Мне нужно загрузить данные в файл CSV, который будет выполнен, и мне нужно загрузить файлы PDF . Также вставьте папку «Изображения», скопируйте ее с DVD на папку на сервере.

+0

В чем проблема? –

ответ

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 
+0

Эта функция решила мой случай. – MMomani

Смежные вопросы