 |
|
ขอรบกวนชี้แนะการ Copy Picture ทั้งโฟลเดอร์ไปสู่อีก Directory ครับ WinApplication |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Imports System
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
DirectoryCopy("D:\Test", "C:\", True)
End Sub
Private Shared Sub DirectoryCopy( _
ByVal sourceDirName As String, _
ByVal destDirName As String, _
ByVal copySubDirs As Boolean)
' Get the subdirectories for the specified directory.
Dim dir As DirectoryInfo = New DirectoryInfo(sourceDirName)
Dim dirs As DirectoryInfo() = dir.GetDirectories()
If Not dir.Exists Then
Throw New DirectoryNotFoundException( _
"Source directory does not exist or could not be found: " _
+ sourceDirName)
End If
' If the destination directory doesn't exist, create it.
If Not Directory.Exists(destDirName) Then
Directory.CreateDirectory(destDirName)
End If
' Get the files in the directory and copy them to the new location.
Dim files As FileInfo() = dir.GetFiles()
For Each file In files
Dim temppath As String = Path.Combine(destDirName, file.Name)
file.CopyTo(temppath, False)
Next file
' If copying subdirectories, copy them and their contents to new location.
If copySubDirs Then
For Each subdir In dirs
Dim temppath As String = Path.Combine(destDirName, subdir.Name)
DirectoryCopy(subdir.FullName, temppath, copySubDirs)
Next subdir
End If
End Sub
End Class
ตามนี้เลยครับ
|
 |
 |
 |
 |
Date :
2015-08-10 12:25:42 |
By :
Thaidevelopment.NET |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ
แต่ขอถามอีกนิดนะครับ ถ้าไฟล์ต้นทางเป็น ไฟล์จาก flash drive จะสามารถทำได้ไหมครับ
|
 |
 |
 |
 |
Date :
2015-08-10 13:34:48 |
By :
golfgee12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คิดว่าทำได้เหมือนกัน ไม่น่าจะมีปัญหาครับ เพียงแค่ระบุพาธต้นทาง ให้ถูกต้องก็พอครับ
|
 |
 |
 |
 |
Date :
2015-08-10 13:47:12 |
By :
Thaidevelopment.NET |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผม Copy path ตามที่เข้าเลยครับ แต่พอรัยแล้วขึ้นแบบนี้

พอจะรู้ไหมครับว่าผิดพลาดที่ตรงไหน มันถึงหาไม่เจอ
|
 |
 |
 |
 |
Date :
2015-08-10 13:55:13 |
By :
golfgee12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พาธผิดไหมคัรบ
|
 |
 |
 |
 |
Date :
2015-08-10 15:26:08 |
By :
Thaidevelopment.NET |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่น่าจะผิดนะครับ เพราะผมก๊อบมาตามนี้เลย


|
 |
 |
 |
 |
Date :
2015-08-10 16:23:49 |
By :
golfgee12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนนี้ผ่านแล้วนะครับ ขอบคุ๊สำหรับคำแนะนำดีๆครับ
|
 |
 |
 |
 |
Date :
2015-08-10 17:11:13 |
By :
golfgee12 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|