Textbox as servername.

deuk11

Member
Joined
May 6, 2012
Messages
6
Programming Experience
Beginner
Hello all,

I'm new here so I don't know if I'm posting this in the right categorie.

But what I want is to make a FTP file upload program, to place some kind of text files into another computer.
The only thing I can't get working is to refer the textbox to the Server location.

Here is my code, hope you guys can help me :) :

Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://(textbox1.text)/var/etc/config.cfg"), System.Net.FtpWebRequest)
request.Credentials = New System.Net.NetworkCredential("root", "dreambox")
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile


Dim file() As Byte = System.IO.File.ReadAllBytes("config.cfg")


Dim strz As System.IO.Stream = request.GetRequestStream()
strz.Write(file, 0, file.Length)
strz.Close()
strz.Dispose()
End Sub
End Class

The Bold thing,, I can't get that to work..

Thanks in advance,
Deuk11 :)
 
It seems a bit ridiculous that you're trying to build an FTP client, which is no trivial matter, and you don't know how to join two Strings together, which is about the most trivial thing you can do in VB. I would suggest that you put the fancy stuff on hold for a little while and find yourself a good beginner tutorial that you can work through from start to finish to get a proper grounding in the basics. You'll be doing yourself a favour in the long run... perhaps even the short run too. This is a good one:

Microsoft Visual Basic .NET tutorials for Beginners

Chapter 2, lesson 4 is about String variables and it includes an example of joining two Strings together. It even contains an example of joining three Strings together, which is a simple extension of the same principle and is what you actually want to do.
 
So.. If I do it like this, it would work? :

Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


Dim FirstName As String
Dim MiddleName As String
Dim LastName As String
Dim FullName As String


FirstName = "ftp://"
MiddleName = "TextBox1.text"
LastName = "/var/etc/CCcam.cfg"


FullName = FirstName & MiddleName & LastName


Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("FullName"), System.Net.FtpWebRequest)
request.Credentials = New System.Net.NetworkCredential("root", "dreambox")
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile


Dim file() As Byte = System.IO.File.ReadAllBytes("CCcam.cfg")


Dim strz As System.IO.Stream = request.GetRequestStream()
strz.Write(file, 0, file.Length)
strz.Close()
strz.Dispose()
End Sub
End Class
 
Look, I got to get this ready by tomorrow because I need it tomorrow.. Could you help me with this so I can study on the basics?

Thanks :)
 
It seems a bit ridiculous that you're trying to build an FTP client, which is no trivial matter, and you don't know how to join two Strings together, which is about the most trivial thing you can do in VB. I would suggest that you put the fancy stuff on hold for a little while and find yourself a good beginner tutorial that you can work through from start to finish to get a proper grounding in the basics. You'll be doing yourself a favour in the long run... perhaps even the short run too. This is a good one:

Microsoft Visual Basic .NET tutorials for Beginners

Chapter 2, lesson 4 is about String variables and it includes an example of joining two Strings together. It even contains an example of joining three Strings together, which is a simple extension of the same principle and is what you actually want to do.


Hey, Actually it works right now except he tells me this message when I open it and click the button:

The remote name cannot be resolved: "textbox1.text"

Is there something to do about it?

Thanks
 
Last edited:
By writing "textbox1.text" you are just entering that value as a string.
If you want to get the Text property of the textbox1 control, then use textbox1.text
 
Back
Top