vb點(diǎn)虐 創(chuàng)建新文件 vbnet fileget

VB.Net怎么創(chuàng)建文件

舉個(gè)例子:

大寧ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!

先引入命名空間:

Imports

System.IOImports

System.Security.AccessControl

代碼:

Dim

sec

As

DirectorySecurity

=

New

DirectorySecurityDim

rule

As

FileSystemAccessRule

=

New

FileSystemAccessRule("Administrator",

FileSystemRights.Delete,

AccessControlType.Allow)sec.AddAccessRule(rule)Directory.CreateDirectory("C:\test",

sec)

這段代碼就是以

Administrator

帳戶

C:\

創(chuàng)建

test

文件夾。

VB.NET 創(chuàng)建文件夾

用Directory.CreateDirectory即可創(chuàng)建文件夾:

'?建立目錄

If?Not?Directory.Exists("C:\負(fù)屃\"??TextBox1.Text)?Then?'檢查文件夾是否存在

Directory.CreateDirectory("C:\負(fù)屃\"??TextBox1.Text)??'不存在,創(chuàng)建文件建夾

End?If

你的例子是因?yàn)樯倭艘粋€(gè)"\"引起的,正確的如下:

Dim?fsotest?As?New?FileSystemObject

If?fsotest.FileExists("C:\負(fù)屃\"??TextBox1.Text)?=?False?Then

fsotest.CreateFolder("C:\負(fù)屃\"??TextBox1.Text) '這里你少了一個(gè)\

End?If

MsgBox("創(chuàng)建成功")

VB中如何實(shí)現(xiàn)創(chuàng)建新的文件夾

分類: 電腦/網(wǎng)絡(luò) 程序設(shè)計(jì) 其他編程語(yǔ)言

解析:

Option Explicit

Dim fso As New FileSystemObject

Dim newfolder As Folder

上面在通用中寫入

下面建立一個(gè)按鈕打入代碼 '后面是解釋

Private Sub Command1_Click()

Set newfolder = fso.GetFolder(InputBox("文件要建立在哪個(gè)盤?如c:")) '這邊也可以用inputbox("要建立的文件夾!")

'創(chuàng)建文件夾

If (fso.FolderExists("c:\windows") = True) Then 'c盤windows是都有的所以用c:\windows

fso.CreateFolder (InputBox("文件的全url?如d:\esinc"))

MsgBox ("新建成功!")

Else

MsgBox ("新建不成功!")

End If

Set newfolder = Nothing

End Sub

當(dāng)前名稱:vb點(diǎn)虐 創(chuàng)建新文件 vbnet fileget
轉(zhuǎn)載注明:http://muchs.cn/article28/ddcjdjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、ChatGPT自適應(yīng)網(wǎng)站、服務(wù)器托管云服務(wù)器、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)