simple question: I have an file online (txt). How to read it and check if its there? (C#.net 2.0)
After you've successfully created a URL , you can call the URL 's openStream() method to get a stream from which you can read the contents of the URL. The openStream() method returns a java. io. InputStream object, so reading from a URL is as easy as reading from an input stream.
A text file on a server can be read with Javascript by downloading the file with Fetch / XHR and parsing the server response as text. Note that the file needs be on the same domain. If the file is on a different domain, then proper CORS response headers must be present.
I think the WebClient-class is appropriate for that:
WebClient client = new WebClient(); Stream stream = client.OpenRead("http://yoururl/test.txt"); StreamReader reader = new StreamReader(stream); String content = reader.ReadToEnd();
http://msdn.microsoft.com/en-us/library/system.net.webclient.openread.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With