Visual Basic:
Trying to get my VB program to run an internal HTML file without it needing to navigate back the the C: drive.
Using:
Private Sub frmMalphite_Load(sender As Object, e As EventArgs) Handles MyBase.Load
LinkLabel1.Links.Add(6, 4, "C:\Users\User\Desktop\Test\Test1\Test2.html")
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
System.Diagnostics.Process.Start(e.Link.LinkData.ToString())
End Sub
I can get the html page to run, however it would not work if I opened the project on another computer, because the absolute path given. Looking for a work around so I don't have to change the path on every computer I use to work on the project.
If the file exists on a drive on MachineA, then the only way you can open this from MachineB is to put the file on a shared drive and access the file via this share.
This will work from any machine that has permissions to read that share.
Something like:
LinkLabel1.Links.Add(6, 4, "\\MachineA\SharedDrive\Test2.html")
You may have access to the hidden administrative share on MachineA (\\MachineA\c$) from MachineB but you can't rely on it.
Related
I am working on an old application running on a Windows CE device. This is old software that is still in use.
As of now, they need to create the folder on the flash drive (there are no drive letters). My idea was to create the folder if missing. However, it gives an error when creating the directory.
The folder is used to save data for later use.
Any ideas on how create a folder from SW?
Here is my VB code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Directory.Exists("QuaData") Then
Directory.CreateDirectory("QuaData")
End If
basically I am making trying to make a folder dialog box, to which if we give a root path it shows me that specific folder and its sub directories and files i don't want the unnecessary folders e.g parent folders of that root folder to appear for this am trying to make a custom(user) folder dialog box control. but still am unsure how to hide the parent folders.
My control in which i give root path: My control output Picture here
In the above picture i dont want to see the unnecessary folders existing above.
I want something like this
I am really confused how to do it ?
Yet there is no way to select custom root folder. Perhaps, you can use custom selected path to navigate directly to your directory before calling dialogue.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FolderBrowserDialog1.SelectedPath = "Your Directory Path"
FolderBrowserDialog1.ShowDialog()
TextBox1.Text = FolderBrowserDialog1.SelectedPath
End Sub
The problem is happening on 2 of the company's computers and on a client computer, but we can not identify a pattern.
I was able to reproduce the error using a simple program that only opens an OpenFileDialog. The program must be run by the generated executable itself (NOT by Debug) and it is still running in the background even after closing. Below is the code of the program, along with a link to download the project and a video demonstrating the error.
Code:
Public Class Form1
Private ofdAbrir As Windows.Forms.OpenFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ofdAbrir = New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
ofdAbrir.Dispose()
ofdAbrir = Nothing
End Sub
End Class
As you can see in the code above, I only have one form, so it is not the case that some form remains open and it is also not related to threads running since none is created.
To reproduce the problem, click on Button1, cancel the OpenFileDialog and try to close the form (clicking on X). The form apparently will close, but you will see at task manager that it still running. The big mystery is that this problem does not happens in all computers.
Video: https://drive.google.com/open?id=1sfdVUGQlwYNCQkl1Ht-cJSOb4433sqnT
Project: https://drive.google.com/open?id=1d4oJYUjaaZ9xnRj4CX3HXOQPqwMZmE0V
I couldn't reproduce the problem, but how about using this method:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Using ofdAbrir As New Windows.Forms.OpenFileDialog
ofdAbrir.ShowDialog()
MsgBox(ofdAbrir.FileName)
End Using
End Sub
I've seen the video u posted...It is not your application that is running rather it is the vsHost.exe that is running :)...The problem shouldn't occur if u run the app outside visual studio.
If the problem is still there,just disable Enable Diagnostic Tools while debugging from Tools > Options > Debugging > Uncheck Enable Diagnostic Tools while debugging
Also u can disable Visual Studio hosting service from Project > Project Properties > Uncheck Enable the Visual Studio hosting service
I have a button in visual basic. I would like, when I hit the button for it to open up the TCP/IPv4 dialog window of the active network connection on the machine so that I can quickly and easily change ip address settings.
I can't seem to find a way to google this properly. All ways I can think to ask the question return unrelated results.
How do I open this dialog window with VB code?
Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
End Sub
I'm not too sure if you can get it to open up straight at the WiFi properties of the current connection, but you can get it to open the Network Connections which should be able to save you some time.
Private Sub Button27_Click(sender As Object, e As EventArgs) Handles Button27.Click
Process.Start("ncpa.cpl")
End Sub
You cant open it directly but this article has a method using #Werdna's approach of using ncpa.cpl and send keys.
It also has the command line utilities for extracting / setting the ip.
https://superuser.com/questions/735292/how-to-open-tcp-ip-properties-from-cmd-or-run-directly
I'm essentially trying to figure out a simple method for deleting a relative path in vb. I want a user to be able to run the program and delete a specific folder within the AppData/Local folder on Windows. The purpose of the program is to remove Google Chrome user data when the user is finished with their session. I'm running in to trouble with:
My.Computer.FileSystem.DeleteDirectory
I'm trying to use this method to remove all folders within the \Google folder. The problem is, that since the \Google folder is relative, if anybody besides me tries to use it, it simply wont work since I would use: My.Computer.FileSystem.DeleteDirectory("C:\Users\Erik\AppData\Local\Google", FileIO.DeleteDirectoryOption.DeleteAllContents). How can I modify this program to remove the \Google folder under whichever user profile the program happens to be executed under?
You can do this with the Environent Paths:
Imports System.IO
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Directory.Delete(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\Google")
End Sub
End Class
This gets the Local Appdata Path for the current User.