Getting IP Address of the Computer

Drags111

Member
Joined
Oct 21, 2007
Messages
20
Programming Experience
1-3
Hello, I am making an auth system for my program, and it needs to get the IP address of the computer using it, and compare it to a list on the Internet. I'm trying to figure out how to do this. Heres a list of things I need to learn, if you guys wanna help out.

1. How to get the IP address of the current computer. < DONE!
2. How to Read and Maniplulate a text file in the folder that the Program's exe is in.
3. How to send data (IP) to a txt file on my webhosting.
4. How to Read data from a txt file on my webhosting.

If you could help me out, this would be great! I'll be looking these things up in the mean time. If you want to MSN me, I'll be on. Thanks!
 
Last edited:
Ok, I figured out about getting the IP address. So i tested it, and the IP it came up with is different from what IP address websites say, and the other ones all say the same thing. The one this comes up with is 192.168.*.** And the others are way different. Anyway heres the code im using:

VB.NET:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName())

        Dim ipfull As String = h.AddressList.GetValue(0).ToString
        Dim ipsplit As String()

        ipsplit = ipfull.Split(".".ToCharArray())

        TextBox1.Text = ipsplit(0)
        TextBox2.Text = ipsplit(1)
        TextBox3.Text = ipsplit(2)
        TextBox4.Text = ipsplit(3)

    End Sub

End Class


EDIT: It only gets the Internal IP, not the External
 
Last edited:
VB.NET:
Dim client As New Net.WebClient
Dim ipstring As String = client.DownloadString("http://whatismyip.com/automation/n09230945.asp")
WebClient also have other Download/Upload methods.

For receiving data on the webserver you can set up a webservice or just an 'empty' upload page with this code:
VB.NET:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Request.ContentLength > 0 Then
        Dim sr As New IO.StreamReader(Request.InputStream, Request.ContentEncoding)
        Dim UploadedString As String = sr.ReadToEnd
        sr.Close()
        Response.End()
    End If
End Sub
To read/write a textfile I would use the StreamReader/StreamWriter of System.IO namespace.
 
Here is also a thread about uploading files that you should read through, it discusses different methods for this.

I'm not open for MSN.
 
k thanks.

So in my code, if I'm trying to write to a txt file using a StreamWriter, what do i do?

Dim itw As New IO.StreamWriter???
 
Im getting an error when i try to post this: (FTP)

webc.Credentials = New Net.NetworkCredential("******* ", "********")
webc.UploadFile("ftp://ftp.php0h.com/gmaccounts.dragscave.com/", "c:\test2")


Heres the error: A first chance exception of type 'System.Net.WebException' occurred in System.dll
 
Last edited:
Really what I want to know is how to send Text to a file like website.com/file.txt. Modifiy, not create or erase other data. Can anyone help?
 
Back
Top