Upload documents using http

  • Thread starter Thread starter eirinliby
  • Start date Start date
E

eirinliby

Hello.

How do I upload a document using http?

I see that .net has the system.web namespace but I cant find any
examples on how to use it... I'm not very experienced in .net.

Thank you very much for any contribution to my problem :)

neoret
 
Hello.

How do I upload a document using http?

I see that .net has the system.web namespace but I cant find any
examples on how to use it... I'm not very experienced in .net.

Thank you very much for any contribution to my problem :)

neoret

this example reads a text file from a remote site

using System;
using System.IO;
using System.Windows.Forms;
using System.Configuration;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Runtime.Remoting;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Web;

namespace test
{
class remoteread
{
// static string Method = "MainAppForm";
static string methodname = "main";

[STAThread]
static void Main()
{
string RemoteFolder = @"http://yoursite.com/";
string RemoteFile = "yourfile.txt";
string url = RemoteFolder + RemoteFile;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader sr = new StreamReader(webResponse.GetResponseStream(), Encoding.ASCII);
string filecontent;
filecontent = sr.ReadLine();

// Create a local StreamWriter here and write one line at a time in the loop

while (filecontent.Length > 0)
{
// Write to your local file here
filecontent = sr.ReadLine();
}
sr.close();
}
}
}

hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top