网站建设资讯

NEWS

网站建设资讯

VB.Net的扩展名 vbnet filestream

vb点虐 ,知道一个文件的扩展名,如何通过这个扩展名获得该文件的默认打开方式(即默认打开程序)?

如没有现存的御消办法的话只能读取注册表,以txt文件为类:

创新互联专业为企业提供泉港网站建设、泉港做网站、泉港网站设计、泉港网站制作等企业网站建设、网页设计与制作、泉港企业网站模板建站服务,10余年泉港做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

HKEY_CLASSES_ROOT\.txt   '在这哗卜个地址有个默认属性值是:txtfile

HKEY_CLASSES_ROOT\txtfile\shell\open\command   '这里的默认属性值txtfile的关联程序:%SystemRoot%\system32\NOTEPAD.EXE %1

我暂不了解vb点虐 读注册表函数(刚在学),以vbs为类:

Dim WshShell

Set WshShell = WScript.CreateObject("Wscript.Shell")

Dim Ext

ext= WshShell.RegRead 乱拆穗("HKEY_CLASSES_ROOT\.mp3\") '这里的扩展名.mp3可以改成其它的看看

MsgBox WshShell.RegRead ("HKEY_CLASSES_ROOT\"  ext  "\shell\open\command\")

怎么用VB.NET更改文件扩展名

以修郑困锋改“尺孝C:\abc.txt"喊晌为bat为例。

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Myfile As String

Myfile = IO.Path.ChangeExtension("C:\abc.txt", ".bat")

Microsoft.VisualBasic.FileSystem.Rename("C:\abc.txt", Myfile)

End Sub

End Class

vb点虐 ,知道一个文件的扩展名,如何获得该类型文件的默认打开程序。

Public Function GetTypeFilePath(ByVal mType As String)

激晌  mType = mType.Trim

If mType.Substring(0, 1)  "." Then mType = "."  mType

Dim Key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(mType)

Dim Result As String = ""

If Not Key Is Nothing Then

Dim SubKeyValue As Object

Dim Value As String

SubKeyValue = Key.GetValue("")

If Not SubKeyValue Is Nothing Then

Value = SubKeyValue.ToString

Dim SubKey As Microsoft.Win32.RegistryKey, ResultKey As Microsoft.Win32.RegistryKey

SubKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(Value)

If Not SubKey Is Nothing Then

ResultKey = SubKey.OpenSubKey("shell\open\command\", False)

蔽誉              If Not ResultKey Is Nothing Then

Result = ResultKey.GetValue("").ToString

End If

明并锋            End If

End If

End If

Return Result

End Function


网站题目:VB.Net的扩展名 vbnet filestream
文章路径:http://cdweb.net/article/ddpisgi.html