how to transfer files using vb.net
is it possible to transfer files using vb.ne开发者_高级运维t? Cutting the files from a certain directory and copy it to another
You can use the File
class and its Move
method.
Or the FileInfo
class and its MoveTo
method.
If you want to move whole directories, there are the Directory
and DirctoryInfo
classes and their associated Move
and MoveTo
methods.
With all of the above, if you do want copies, instead of moving files, use the Copy
and CopyTo
methods, which work similarly to the Move
and MoveTo
methods.
This is applicable to all .NET languages, not only VB.NET.
The FileInfo class has a MoveTo
method that you can use.
try this
Dim dd As New DirectoryInfo(dirname)
For Each ff As FileInfo In dd.GetFiles("*.CSV", SearchOption.TopDirectoryOnly)
ff.CopyTo(sentPath + "\Sent\" + SentFolder + "\" & ff.Name, True) '
If File.Exists(sentPath + "\" & ff.Name) Then
File.Delete(sentPath + "\" & ff.Name)
End If
Next
精彩评论