rowmark
rowmark

Reputation:

What is the Vb.net version of (c#)Cast?

How do I convert the following line into VB.net??

FtpWebRequest uploadRequest =(FtpWebRequest)WebRequest.Create("example.com" + @"/" + "localfile.html");

Upvotes: 0

Views: 181

Answers (4)

Brandon
Brandon

Reputation: 69983

Dim uploadRequest As FtpWebRequest = 
  DirectCast(WebRequest.Create("example.com/localfile.html"), FtpWebRequest)

For future reference, you could just put your code into a C# to VB.NET code converter.

Also I'm not sure what you're doing with website.com. Is that a string? (It's not a valid variable name if thats what its suppose to be).

Upvotes: 6

Jason
Jason

Reputation: 52523

Dim uploadRequest As FtpWebRequest = 
  CType(WebRequest.Create("example.com/localfile.html"), FtpWebRequest)

Upvotes: 1

rp.
rp.

Reputation: 17683

You're missing a plus sign before localfile.html:

Dim uploadRequest As FtpWebRequest = DirectCast(WebRequest.Create(website.com + "/" + "localfile.html"), FtpWebRequest)

Upvotes: 0

Joseph
Joseph

Reputation: 25523

Dim uploadRequest as FtpWebRequest = DirectCast(
    WebRequest.Create(websitecom & "/localfile.html", FtpWebRequest)

I'm assuming websitecom is a variable and if that's the case then the "." shouldn't be in it. If it was supposed to be a string then just put it inside the quotations.

Upvotes: 0

Related Questions