vb.net磁盤卷標(biāo),不能設(shè)置磁盤卷標(biāo)的操作為

vb.net如何獲取電腦中的所有盤符

首先使用 System.IO.DriveInfo.GetDrives()獲取System.IO.DriveInfo,存入ds()

創(chuàng)新互聯(lián)是專業(yè)的離石網(wǎng)站建設(shè)公司,離石接單;提供網(wǎng)站設(shè)計(jì)、做網(wǎng)站,網(wǎng)頁設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行離石網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來合作!

然后遍歷ds,獲取各個(gè)信息部分。

Dim ds() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()

For i As Integer = 0 To ds.Length - 1

TextBox1.Text = TextBox1.Text + ds(i).DriveType.ToString + " " '驅(qū)動(dòng)器類型

TextBox1.Text = TextBox1.Text + ds(i).Name + " " '盤符(驅(qū)動(dòng)器名)

TextBox1.Text = TextBox1.Text + ds(i).IsReady.ToString + " " '是否就緒

If ds(i).IsReady = True Then

TextBox1.Text = TextBox1.Text + ds(i).VolumeLabel + " " '卷標(biāo)

TextBox1.Text = TextBox1.Text + ds(i).TotalSize.ToString + " " '驅(qū)動(dòng)器容量

TextBox1.Text = TextBox1.Text + ds(i).TotalFreeSpace.ToString '驅(qū)動(dòng)器可用容量

End If

TextBox1.Text = TextBox1.Text + vbNewLine

Next

關(guān)于 VB.NET 2008中U盤的插拔

一下代碼將自動(dòng)完成檢測:

Imports System.IO

Public Class Form1

Public Const WM_DEVICECHANGE = H219

Public Const DBT_DEVICEARRIVAL = H8000

Public Const DBT_DEVICEREMOVECOMPLETE = H8004

Dim DriveLetter As String

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If m.Msg = WM_DEVICECHANGE Then

Select Case m.WParam

Case DBT_DEVICEARRIVAL

Dim s() As DriveInfo = DriveInfo.GetDrives

For Each drive As DriveInfo In s

If drive.DriveType = DriveType.Removable Then

DriveLetter = drive.Name.ToString()

Debug.WriteLine("U盤 :" DriveLetter "已插入.")

End If

Next

Case DBT_DEVICEREMOVECOMPLETE

Dim s() As DriveInfo = DriveInfo.GetDrives

For Each drive As DriveInfo In s

If drive.ToString = DriveLetter Then Exit Sub

Next

Debug.WriteLine("U盤:" DriveLetter "已卸載!")

End Select

End If

MyBase.WndProc(m)

End Sub

End Class

Vb如何獲取系統(tǒng)卷標(biāo)磁盤名字各是什么? 急求,謝啦

添加對應(yīng)DriveListBox控件

代碼如下:

n?=?Drive1.ListCount

For?i?=?0?To?n?-?1

Drive1.ListIndex?=?i

DrvName?=?Left(Drive1.Drive,?2)'這是盤符名

DrvLabel?=?Mid(Drive1.Drive,?3,?Len(Drive1.Drive)?-?2)?'這是卷標(biāo)名

'需要說明的是:卷標(biāo)名如果為默認(rèn)名稱,讀到是空的,可加個(gè)if顯示為“本地磁盤”

Print?DrvName,?DrvLabel

Next?i

需要幫忙,向我求助好了~ ?兩頁一答!

當(dāng)前題目:vb.net磁盤卷標(biāo),不能設(shè)置磁盤卷標(biāo)的操作為
URL網(wǎng)址:http://muchs.cn/article40/hcpcho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站、建站公司企業(yè)網(wǎng)站制作、ChatGPT、云服務(wù)器

廣告

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

成都app開發(fā)公司