Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. copying a file to the web

copying a file to the web

Scheduled Pinned Locked Moved C#
comhelpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rob Tomson
    wrote on last edited by
    #1

    how can i copy a file to a website, ie. file.ext ---> http://site.site.com/folder it's not ftp, it's http that i need to use. any help would be great. thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.

    D 1 Reply Last reply
    0
    • R Rob Tomson

      how can i copy a file to a website, ie. file.ext ---> http://site.site.com/folder it's not ftp, it's http that i need to use. any help would be great. thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      If no FTP is available, you're going to have to find out if the site supports file posts via http and what http form or mechanism is supposed to be used. There's no generic way of doing it that works for all sites. Other than FTP that is... RageInTheMachine9532

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        If no FTP is available, you're going to have to find out if the site supports file posts via http and what http form or mechanism is supposed to be used. There's no generic way of doing it that works for all sites. Other than FTP that is... RageInTheMachine9532

        R Offline
        R Offline
        Rob Tomson
        wrote on last edited by
        #3

        the way i've been putting my files in is creating a webfolder in windows and then copying my file(s) onto the site. just out of curiosity how do i upload a file via ftp also? thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.

        T H 2 Replies Last reply
        0
        • R Rob Tomson

          the way i've been putting my files in is creating a webfolder in windows and then copying my file(s) onto the site. just out of curiosity how do i upload a file via ftp also? thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.

          T Offline
          T Offline
          Tom Larsen
          wrote on last edited by
          #4

          (this isn't really a C# topic but whatever :-)) Go to google and find a FTP client. There are some ones that present users with a drag and drop interface for you.

          1 Reply Last reply
          0
          • R Rob Tomson

            the way i've been putting my files in is creating a webfolder in windows and then copying my file(s) onto the site. just out of curiosity how do i upload a file via ftp also? thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            What you're using then is WebDAV, which uses different HTTP headers to post files. Try a search in google for more information. To upload files using FTP, you can P/Invoke the relevent WinInet APIs or create your own WebRequest/WebResponse derivative classes (there's plenty of documentation about this in the .NET Framework SDK) that implements that simple FTP protocol, which you can also find plenty of information about by searching with google.

            Microsoft MVP, Visual C# My Articles

            R 1 Reply Last reply
            0
            • H Heath Stewart

              What you're using then is WebDAV, which uses different HTTP headers to post files. Try a search in google for more information. To upload files using FTP, you can P/Invoke the relevent WinInet APIs or create your own WebRequest/WebResponse derivative classes (there's plenty of documentation about this in the .NET Framework SDK) that implements that simple FTP protocol, which you can also find plenty of information about by searching with google.

              Microsoft MVP, Visual C# My Articles

              R Offline
              R Offline
              Rob Tomson
              wrote on last edited by
              #6

              just an update; i succesfully wrote a text string to a file on an http site. if you have any suggestions please let me know. private void publish() { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; this.btnPublish.Enabled = false; this.btnPublish.Text = "Wait..."; System.Net.WebClient client = new System.Net.WebClient();; string fullPath; string fileText; byte[] byteArray; System.IO.Stream stream; System.IO.StreamWriter sWriter; fullPath = this.xml.Find("BaseURL") + '/' + this.xml.Find("PublishName") + ".ics"; fileText = this.convertiCal(); byteArray = System.Text.Encoding.ASCII.GetBytes(fileText); client.Credentials = new System.Net.NetworkCredential(this.xml.Find("Login"), this.xml.Find("Password")); stream = client.OpenWrite(fullPath, "PUT"); sWriter = new System.IO.StreamWriter(stream); sWriter.Write(fileText); try { sWriter.Flush(); sWriter.Close(); } catch (System.Net.WebException err) { System.Windows.Forms.MessageBox.Show(err.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK); } client.Dispose(); this.btnPublish.Text = "&Publish"; this.btnPublish.Enabled = true; this.Cursor = System.Windows.Forms.Cursors.Default; } thanks for the help, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups