用Directory.CreateDirectory即可創(chuàng)建文件夾:
創(chuàng)新互聯(lián)建站-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比喀喇沁網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式喀喇沁網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋喀喇沁地區(qū)。費用合理售后完善,十余年實體公司更值得信賴。
'?建立目錄
If?Not?Directory.Exists("C:\負屃\"??TextBox1.Text)?Then?'檢查文件夾是否存在
Directory.CreateDirectory("C:\負屃\"??TextBox1.Text)??'不存在,創(chuàng)建文件建夾
End?If
你的例子是因為少了一個"\"引起的,正確的如下:
Dim?fsotest?As?New?FileSystemObject
If?fsotest.FileExists("C:\負屃\"??TextBox1.Text)?=?False?Then
fsotest.CreateFolder("C:\負屃\"??TextBox1.Text) '這里你少了一個\
End?If
MsgBox("創(chuàng)建成功")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim AppPath As String = Directory.GetCurrentDirectory() '獲取應用程序的當前工作目錄 Process.Start(AppPath) '打開當前目錄 End Sub
我也找來的,只找到這個,希望對你有幫助。
Dim
dir
As
New
IO.DirectoryInfo("C:\TDDownload")
//
目錄下就一個文件夾
If
dir.GetDirectories.Length
Then
MessageBox.Show(dir.GetDirectories.GetValue(0).ToString())
End
If
//
目錄下多個文件夾
'For
Each
d
As
IO.DirectoryInfo
In
dir.GetDirectories
'
MessageBox.Show(d.FullName)
'Next
OpenFileDialog openFile = new OpenFileDialog();
openFile.Multiselect = true;
openFile.Filter = "圖片 (*.jpg)|*.jpg|所有文件 (*.*)|*.*";
if (openFile.ShowDialog() == DialogResult.OK)
{
string ss = openFile.FileName;
string ww = openFile.FileName.Remove(openFile.FileName.Length - 4, 4);
File.Copy(ss, @"..\..\picture\" + Path.GetFileName(ss));
}
上面是先獲取路徑,在把圖片復制到指定路徑下。
System.Windows.Forms.OpenFileDialog
System.Windows.Forms.SaveFileDialog
System.Windows.Forms.FolderBrowserDialog
以上三個類均能夠很好的解決樓主的需求。
具體的請lz自己查msdn
vb.net使用控件FolderBrowserDialog1,在程序中:
'設置對話框中在樹視圖控件上顯示的說明文本
Me.FolderBrowserDialog1.Description = "請選擇輸出報表所在路徑:"
'設置從其開始瀏覽的根文件夾
Me.FolderBrowserDialog1.SelectedPath = "c:\"
If Me.FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then
'取得全路徑(包含文件名)
reportPath1 = System.IO.Path.GetFullPath(Me.FolderBrowserDialog1.SelectedPath)
'設定text顯示文件名
txtReport1.Text = reportPath1
setReportList()
End If
在setReportList()中針對你所需要的文件進行操作等