Jump to content

Loading text file from Internet

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Hi,

Sorry if this seems a bit of a stupid question, I'v not used Visual basic in a long time.

But can somebody help me out, I need to open a text file from the internet into a textbox, however I dont want to download the file, Only open it, Can someone help

Thanks

#2
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
All things taken from the internet is downloaded first, but the thing you probably want to use is a Net.Webclient and using its DownloadString function. :)

#3
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Okay,
But I was thinking more like how it is opened when opening files from your filesystem.

like my.computer.filesystem.filexists("C:\example.txt") and so on.

#4
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
this:
my.computer.filesystem.filexists("C:\example.txt")
won't open a file, so I don't really get what you mean.
The thing I said before will give you a string containing the source of the page-

#5
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Okay, Basically I want to do how you open a picture from the internet like this
picture1.picturelocation = ("http://randomsite.com/randomimage.jpg")
but for a text file, something like this
textbox1.filelocation = ("Http://randomsite.com/randomtext.txt


#6
gokuajmes

gokuajmes

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 518 posts
i think use a textreader
TextReader Class (System.IO)

read the text from the URL , then cast that to a string , then assign it like this
TextBox1.Text = (string) Textreadfrom URL;


#7
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
For the textbox thing you can just do the thing with the webclient and downloadstring as I said before.
For the image thingy you can use the downloaddata function to get a byte array and then convert it to an image, I found how to do it here(Windows Developer Blog: Convert image to byte array and vice versa) and I've tested it and it works like a charm.

#8
Blimp

Blimp

    Programmer

  • Members
  • PipPipPipPip
  • 154 posts
Vswe,

I do not want to download the files, I simply want to access the data without downloading it.

Any way of doing that?

#9
so1i

so1i

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 312 posts
To access data from the internet, on your computer... it HAS to be downloaded. Even webpages, when you view them are technically downloaded, even be it temporarily. So in theory, you need to download the text file, then open and read it.

That's just how it works. But for how your program actually works, you wont tell the difference.

#10
anglina

anglina

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
Wow, what a thread!
imacooknotachef.com
Food/Photo Blog

#11
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts

Blimp said:

Vswe,

I do not want to download the files, I simply want to access the data without downloading it.

Any way of doing that?

Nope, so1i have explained why.

#12
anglina

anglina

    Learning Programmer

  • Members
  • PipPipPip
  • 76 posts
I stand by my beliefs: this thread is full of Awesome!
imacooknotachef.com
Food/Photo Blog