I’m making a simple program in which, when you press a button the dialog box with all the directories appears so that you can select and open your document. There is no server or browser or web involvement. In fact, since I’m making the project in Visual Studio, I prefer that it opens in Visual Studio, or at least through it.
This is a bit of a code I wrote in Visual Basic, but it doesn’t actually open the file.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fd As OpenFileDialog = New OpenFileDialog()
Dim strFileName As String
fd.Title = "Open File Dialog"
fd.InitialDirectory = "C:\"
fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 2
fd.RestoreDirectory = True
If fd.ShowDialog() = DialogResult.OK Then
strFileName = fd.FileName
'fd.OpenFile() "strFileName" "Microsoft Visual Studio\Frontend.vb"
Any help or suggestion is appreciated.
I’m not a VB expert, but some stuff you may consider.
Not sure about string escaping in VB, but maybe “C:” should be “C:\”?
Also since it’s about C drive, you may get permission issues! try using another drive, or run the script/app as administrator.
For opening the file using the VS, (is supposed to be)you need simply call the visual studio exe file, and pass the file full path as argument to it. (search for visual studio command line arguments for more info)
Keep going on greta work, happy programming
From a browser(not your case), accessing any local resource is kind of impossible by js becasue of security stuffs.
You may read teh reference here, and remember, not all functions JScript supports are available for other browsers/engine and vice-versa.
Also check this link which like your situation maybe
I suggest for more common(and probably safer) way, you may have a look about CMD and Bash too.
But if you have access to that environment or can package the node runtime, it’s extremely easy.