简体   繁体   English

在Visual Studio中使用vb.net在excel中打开特定的文件夹

[英]Open specific Folder in excel using vb.net in VisualStudio

I have to update an add-in that not written by me and i have to add a button that opens the specific path. 我必须更新一个不是由我编写的加载项,并且必须添加一个用于打开特定路径的按钮。 I have no idea about this add-in. 我对此插件一无所知。 I could just add the button... 我可以添加按钮...

    Private Sub RBOpenFolder_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles RBOpenFolder.OnClick

    End Sub

....\\AppData\\Local\\AppName I have to access this address but the path changes on each pc has this add-in. .... \\ AppData \\ Local \\ AppName我必须访问此地址,但是每台PC上的路径更改都有此加载项。

So in my computer C:\\Users\\Taylan\\AppData\\Local\\AppName 所以在我的计算机上C:\\ Users \\ Taylan \\ AppData \\ Local \\ AppName

Regards 问候

If I am understanding this correctly, you are trying to access the user's local AppData folder via your application. 如果我正确理解这一点,则您正在尝试通过应用程序访问用户的本地AppData文件夹。

To achieve this, simply use the Environment.GetFolderPath and specify the local application data folder: 为此,只需使用Environment.GetFolderPath并指定本地应用程序数据文件夹:

Dim FolderNameAs String

FolderName = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

In your case, this would return: 就您而言,这将返回:

C:\Users\Taylan\AppData\Local\

You will then need to append the remainder of your path to this, so add AppName : 然后,您需要将路径的其余部分附加到此,因此添加AppName

FolderName = System.IO.Path.Combine(FolderName, "AppName")

The FolderName variable will then contain: FolderName变量将包含:

C:\Users\Taylan\AppData\Local\AppName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM