制作文件夹和复制文件 [英] Making folder and copying file
本文介绍了制作文件夹和复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我的应用程序在驱动器 C 的特定文件夹中查找文件(比如 C:\myFolder\abc.mdb),如果找到就给一个消息,如果没有,请在驱动器 C:\ 中创建文件夹,然后复制文件.
I want my application to look for a file in drive C's specific folder (say C:\myFolder\abc.mdb), if found just give a message if not, make the folder in drive C:\ and then copy the file.
如何做到这一点?谢谢弗坎
How to do this? Thanks Furqan
推荐答案
您可以使用 File
、Directory
和 Path
对象在System.IO
如下图:
You could use the File
, Directory
, and Path
objects in the System.IO
as shown below:
Imports System.IO
...
Dim path As String = "C:\myFolder\abc.mdb"
If File.Exists(path) Then
'TODO write code to create message'
Else
Dim folder As String = Path.GetDirectoryName(path)
If Not Directory.Exists(folder) then
Directory.CreateDirectory(folder)
End If
'TODO code to copy file from current location to the newly created directory path'
'i.e. File.Copy(FileToCopy, NewCopy)'
End If
这篇关于制作文件夹和复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文