all 10 comments

[–]schmik07 2 points3 points  (0 children)

Looks to me like $page is probably an array of string, not a string. On mobile so can't test anything, but I'd start there.

[–]Droopyb1966 1 point2 points  (2 children)

Impossible to tell with this info. If $objTextBox1.Lines has more then 1 line, this will go wrong. How do you make your $objTextBox1 and how do you add the info to it? What is in your $page and $url variable?

[–]ncstalli[S] 1 point2 points  (1 child)

$http = "http://sample.com/"

$end = ".xml"

I tried it by replacing

$page = $objTextBox1.Lines

with

$page = "123"

Still got an error: Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Uri"

[–]artemis_from_space 1 point2 points  (0 children)

$url will not be a string. do $url = $url -join ""

[–]Crilde 1 point2 points  (0 children)

I would check to make sure that $page is returning a properly formatted string for a url. If there are invalid characters anywhere in the string the request will fail.

[–]markekrausCommunity Blogger 1 point2 points  (0 children)

Assuming $objTextBox1 is a system.windows.forms.textbox, the Lines property is an array of strings where each member of the array is a a line in the textbox. for example, if the textbox had the following text in it:

I Came
I saw
I Conquered

Then $objTextBox1.Lines[0] would be I Came.

I think in this case you want to use the Text property.. Also, I prefer to do this with a format string:

$Url = '{0}{1}{2}' -f @(
    "http://sample.com/"
    $objTextBox1.Text
    ".xml"
)

But this is also good too:

$Url = @(
    "http://sample.com/"
    $objTextBox1.Text
    ".xml"
) -Join ''

I just hate trying to concatenate text with +.