![]() |
| | #1 |
| Registered User Join Date: Sep 2006
Posts: 98
| Reading text files on the internet Code: string user="C:\stuff\text.txt";
string tmp="";
using (FileStream fs = File.Open(user, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
byte[] b = new byte[1024];
UTF8Encoding temp = new UTF8Encoding(true);
while (fs.Read(b, 0, b.Length) > 0)
{
tmp += (temp.GetString(b));
}
}
Thanks |
| Mavix is offline | |
| | #2 |
| Registered User Join Date: Sep 2006
Posts: 98
| I just read on another forum that I would have to download the file first and then access it locally like I do now. Does anyone know how I can download the file? |
| Mavix is offline | |
| | #3 |
| and the Hat of Clumsiness Join Date: Oct 2002
Posts: 1,101
| The power of Google. First item: http://www.primaryobjects.com/CMS/Article64.aspx I havent looked at this article in detail but it will definately help you achieve your goal. |
| GanglyLamb is offline | |
| | #4 |
| Registered User Join Date: Sep 2006
Posts: 98
| Well, I figured out how to do it. I used Code: string url="http://www.textfiles.com/text.txt"; WebRequest request = WebRequest.Create(url); request.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string data = reader.ReadToEnd(); reader.Close(); dataStream.Close(); response.Close(); |
| Mavix is offline | |
| | #5 |
| Registered User Join Date: Jan 2003
Posts: 120
| did you try to read it in and store it, then alter it, then use StreamWriter to write it back?
__________________ All Your Base Are Still Belong to Someone!!! And you Remember that!!! |
| AtomRiot is offline | |
| | #6 |
| Registered User Join Date: Sep 2006
Posts: 98
| I have now, but I don't know how to do that. Could you perhaps give me an example of how to do it? |
| Mavix is offline | |
| | #7 |
| Registered User Join Date: Jan 2003
Posts: 120
| well chances are you will have to upload it via some http since most web sites do not have direct write access to the files you can view.
__________________ All Your Base Are Still Belong to Someone!!! And you Remember that!!! |
| AtomRiot is offline | |
| | #8 |
| Registered User Join Date: Jan 2003
Posts: 120
|
__________________ All Your Base Are Still Belong to Someone!!! And you Remember that!!! |
| AtomRiot is offline | |
| | #9 |
| Registered User Join Date: Sep 2006
Posts: 98
| Thanks for the link! How can I upload using http? |
| Mavix is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use FTP? | maxorator | C++ Programming | 8 | 11-04-2005 03:17 PM |
| reading text files | stimpyzu | C++ Programming | 11 | 04-17-2004 07:45 AM |
| Reading binary files and writing as text | thenrkst | C++ Programming | 8 | 03-13-2003 10:47 PM |
| Reading spaces, carrage returns, eof from text files | thenrkst | C++ Programming | 1 | 03-11-2003 05:18 AM |
| reading certain parts of text files | Captain Penguin | C++ Programming | 2 | 10-10-2002 09:45 AM |