为什么这不适用于Visual Basic? [英] Why isn't this working in Visual Basic?
本文介绍了为什么这不适用于Visual Basic?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Shell("net use F: \\Servername\share")
End Sub
我知道还有其他方法可以做到这一点,但这是我的问题。上次有人回答时没有映射驱动器使用UNC路径并且没有给出示例代码并且从未回答过我的问题。我是编程新手,这似乎是最简单的方法。
I understand there are other ways to do this but this is my question. Last time someone answered don't map a drive use UNC path and gave no example code and never answered my question. I am new to programming and this seems to be the easiest way.
推荐答案
我强烈建议完全避免使用基本的API,专注于合法的.NET FCL,你可以使用,特别是类System.Diagnostics.Process
:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v = vs.110%29.aspx [ ^ ],
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.start%28v=vs.110%29.aspx [ ^ ]。
-SA
I would strongly recommend avoiding to use Basic-specific API at all, focusing on legitimate .NET FCL, where you can use, in particular, the classSystem.Diagnostics.Process
:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.start%28v=vs.110%29.aspx[^].
—SA
Net use command [ ^ ]将计算机与共享资源连接或断开连接,或显示有关计算机连接的信息。 br />
在VB.NET中你必须使用 ManagementClass类 [ ^ ]。
请参阅:如何使用vb.n共享该文件夹et code [ ^ ]
注意:运行的用户这样的程序需要具有相应的权限。
Net use command[^] connects a computer to or disconnects a computer from a shared resource, or displays information about computer connections.
In VB.NET you have to use ManagementClass class[^].
Please, see: How to share the folder using vb.net code[^]
Note: a user which runs such of programme need to have proper permissions to do that.
这篇关于为什么这不适用于Visual Basic?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文