详细解决方案
VB.NET 判断光驱盘符,该怎么解决
热度:162 发布时间:2016-04-25 02:25:48.0

初学VB.NET
以上代码是今天从网上看到,想测试一下看不行。
问题:
1、If FsoDrive.DriveType = CDRom Then 显示未声明CDRom,想咨询一下怎么办?
2、Function不是需要Return返回值吗?此程序没有怎么返回?
针对以上问题
自己修改了一下,笔记本运行,笔记本带有光驱,但是结果还是显示“无CDRom”,代码如下:
Function GetCDROM()
Dim Fanhui as string ="" ’用于返回值
Dim Fso As New Scripting.FileSystemObject
Dim FsoDrive As Scripting.Drive, FsoDrives As Scripting.Drives
FsoDrives = Fso.Drives
For Each FsoDrive In FsoDrives
If FsoDrive.DriveType = 4 Then ‘查询网上,4代表光驱
Fanhui = FsoDrive.DriveLetter
Else
Fanhui = "无CDRom"
End If
Next
Return Fanhui
Fso = Nothing
FsoDrive = Nothing
FsoDrives = Nothing
End Function
请各位大侠帮帮忙
------解决方案--------------------
先引用filesystem组件
.net下应该有更方便的方法
DriveInfo.DriveType
------解决方案--------------------
请这样写:
Imports System.IO
Public Class RECDRom
Public Function GetCDROM() As String
Dim str1 As String = ""
For Each hh In DriveInfo.GetDrives
If hh.DriveType = IO.DriveType.CDRom Then
str1 = hh.Name
Exit For
End If
Next
Return str1 '返回空时,没有光驱,否则返回光驱盘符。
End Function
end class
------解决方案--------------------
网页你也只能获取服务器的.又不能获取本地的..写了也没什么用.
相关解决方案
- System.setProperty("javax.net.ssl.keyStore 多个之间冲突解决方法
- HttpURLConnection偶然会出现 java.net.UnknownHostException,这是为什么呢
- 页面刷新时怎么进行csrf token 判断
- extjs 3+strust2的Excel下载 java.net.SocketException解决方案
- 处理https访问时URL.openConnection()返回com.sun.net.ssl.HttpsURLConnection,各位大侠请帮忙看看,该如何处理
- Can not find the tag library descriptor for "http://struts-menu.sf.net/tag"解决思路
- 憋了很久的有关问题-java.net.SocketTimeoutException: Read timed out
- 大四应届生(在校重要学java),面试携程(只有.net职位),该不该转.net
- 新装的tomcat,启动就报错:java.net.SocketException: select failed,该怎么处理
- IP 连接失败。 java.net.ConnectException: Connection timed out: connect
- org.apache.commons.net.ftp 怎么获取服务器端所有文件的详细信息
- webservice发布没有关问题 调用时axisfault:java.net.ConnectException: Connection refused: conn
- asp.net 连接数据库,该如何解决
- Caused by: java.net.ConnectException: Connection timed out: connect
- 服务器端 怎么 获取 客户端的物理地址(mac)
- java连接ftp,用127.0.0.1可以连接成功并上传,但用本地已设置的IP则出错:java.net.ConnectException: Connection refused: connect,该如何处理
- 大家帮忙看个有关问题啊。java.net.UnknownHostException: java.sun.com
- 实现下载功能出现java.net.SocketException: Connection reset by peer: socket write error,该如何解决
- java.net.ProtocolException: Server redirected too many times (20),该如何解决
- 怎么解决java.net.SocketTimeoutException: Read timed out这个有关问题
- javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated错误
- ClientAbortException: java.net.SocketException: Connection reset by peer: sock解决方法
- java.lang.ClassNotFoundException: net.sf.json.JSONObject,该如何处理
- javascript有木有java.net.URLEncoder.encode类似的函数?解决方法
- 急java.net.ConnectException: 不允许联接,该如何解决
- 急需解决:java.net.ConnectException: Connection timed out: connect,该如何解决
- sun.net.ftp.FtpProtocolException: NLST :500 'NLST '
- 原来很正常的hibernate联接mysql,突然报:java.net.ConnectException: Connection refused: connect
- 咨询关于com.enterprisedt.net.ftp.FTPClient 在 Timer下使用的有关问题
- 学JSP还是ASP.NET?该怎么解决