Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FtpWebRequest - Help Needed
#2
(01-04-2012, 01:39 PM)Die Wrote: Alright, well now that I got my program working I need to make it so I can share it with other users.

Instead of having my Username and Password in the source, I want it to be "TextBox1.Text and TextBox2.Text.
I know this is an easy fix, I just have never had to do this so I'd appreciate it if someone helped.

My Code:
Code:
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://ftp.drivehq.com/My+Documents/file.exe"), System.Net.FtpWebRequest)
        request.Credentials = New System.Net.NetworkCredential(("Textbox1.Text"), ("Textbox2.Text"))
        request.Method = System.Net.WebRequestMethods.Ftp.UploadFile

        Dim file() As Byte = System.IO.File.ReadAllBytes(TextBox3.Text)

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

Problem:
request.Credentials = New System.Net.NetworkCredential(("Textbox1.Text"), ("Textbox2.Text"))

Doesn't show up as an Error, but when you use the program its self it doesn't log you in.

===
I will be willing to give the full source to a few users that I think would actually try to fix it.

If you help fix this, and would like to continue helping with problems I would greatly appreciate it and I will put you in the credits.

AIM:x.Epiphany (Preferred)

Code:
request.Credentials = New System.Net.NetworkCredential(("Textbox1.Text"), ("Textbox2.Text"))

Why are you turning variables of string values into string values themselves?

For example IF:
• Textbox1.Text = "MyValue"

Then:
• Textbox1.Text = "MyValue"
BUT
• "Textbox1.Text" = "Textbox1.Text"

You're explicitly defining that as a string value itself. And you also don't need brackets around them.

Get rid of System.Net and import it as well.
Code:
Imports System.Net
Code:
request.Credentials = New NetworkCredential(Textbox1.Text, Textbox2.Text)

Don't turn into a copy and paste coder, you're not getting anywhere by doing that. And I can see that if you don't understand how types work, that you probably didn't make this. Learn the basics for yourself, and try to code things on your own. Work from beginner stages and move up.
Reply


Messages In This Thread
FtpWebRequest - Help Needed - by Die - 01-04-2012, 01:39 PM
RE: FtpWebRequest - Help Needed - by AceInfinity - 01-04-2012, 02:11 PM
RE: FtpWebRequest - Help Needed - by Die - 01-04-2012, 02:18 PM
RE: FtpWebRequest - Help Needed - by Die - 01-04-2012, 02:38 PM
RE: FtpWebRequest - Help Needed - by Die - 01-04-2012, 03:50 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)