hi
wts the code for the IP Address to be viewed as string?
and is there also a code to create folder?
Printable View
hi
wts the code for the IP Address to be viewed as string?
and is there also a code to create folder?
Create a folder:
VB Code:
My.Computer.FileSystem.CreateDirectory("C:\NewFolder")
Not sure how to find out the IP address from VB but the "ipconfig" utility can be used to display it.
Would this be for a web app?
no.. its for the IP of the users comp
You could get the computer name and use that instead?
no. The IP Address is needed.. i think its in the command Net. -
There are probably some third-party components you could use. I'll do a bit of research and let you know if I find anything... What kind of program are you making?
Ok here are a couple of ways to do it then.
VB Code:
Imports System.Net Imports System.Net.Sockets Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ipHostInfo As IPHostEntry = Dns.Resolve(Dns.GetHostName()) MsgBox(ipHostInfo.AddressList(0).ToString) End SubVB Code:
MessageBox.Show(Net.Dns.GetHostByName(System.Environment.MachineName).AddressList(0).ToString)
thx. the 2nd 1 worked
web stuffQuote:
Originally Posted by dom_stapleton
Both of them work for me! Cheers, RobDog, they might come in handy in the future. Although VS 2005 advised that I replace both Resolve and GetHostByName with GetHostEntry instead, as they are obselete. Probably not vitally important but worth nothing I suppose...
Thanks. :)
Yes, its 2003 code so I cant say what changed in 2005. ;)