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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. file sending

file sending

Scheduled Pinned Locked Moved C#
help
5 Posts 5 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.
  • V Offline
    V Offline
    Vivek Vijayan
    wrote on last edited by
    #1

    m doin an applciation- file sending thru socket- i think its send as bytes.but wht funcitoon i can use to send it. do i need to save it to a temporary location to convert it to bytes can any one help me

    This code was posted by me...

    X I N R 4 Replies Last reply
    0
    • V Vivek Vijayan

      m doin an applciation- file sending thru socket- i think its send as bytes.but wht funcitoon i can use to send it. do i need to save it to a temporary location to convert it to bytes can any one help me

      This code was posted by me...

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      send bytes in a specific format, like first of all send a long value that is the size of file and then keep send file's data in bytes...and at receiver-end first read that long value and write those bytes direct to file... use Socket.Send() to send bytes...

      Vivek Vijayan wrote:

      do i need to save it to a temporary location to convert it to bytes

      no, .Net does itself...you can use either System.IO.File.ReadAllByte() if file size is smaller than 2GB or use FileStream have a look at these An Asynchronous Socket Server and Client[^] File Transfer using Socket Application in C#.Net 2[^]

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

      ----------------------------------------------- 128 bit encrypted signature, crack if you can

      1 Reply Last reply
      0
      • V Vivek Vijayan

        m doin an applciation- file sending thru socket- i think its send as bytes.but wht funcitoon i can use to send it. do i need to save it to a temporary location to convert it to bytes can any one help me

        This code was posted by me...

        I Offline
        I Offline
        Ian Shlasko
        wrote on last edited by
        #3

        I believe the function is called: System.IO.File.GetAllBytes() Or something like that. Granted, if it's a big file, you probably want to stream it a chunk at a time, using an algorithm kind of like this:

        byte[] buffer = new byte[BUFFER_SIZE];
        StreamReader sr = ...open the file...
        while (!sr.EndOfStream)
        {
        int numBytes = sr.Read(buffer, 0);
        yourNetworkStreamWriter.Write(buffer, 0, numBytes);
        }

        Proud to have finally moved to the A-Ark. Which one are you in? Developer, Author (Guardians of Xen)

        1 Reply Last reply
        0
        • V Vivek Vijayan

          m doin an applciation- file sending thru socket- i think its send as bytes.but wht funcitoon i can use to send it. do i need to save it to a temporary location to convert it to bytes can any one help me

          This code was posted by me...

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Vivek Vijayan wrote:

          m doin an applciation- file sending thru socket- i think its send as bytes

          Yes. It will be send as several chunks of bytes.

          Vivek Vijayan wrote:

          wht funcitoon i can use to send it.

          Your message says you are just a beginner. So try with TcpListener and TcpClient classes. However, the best way to do network programming is to work with Socket class directly.

          Vivek Vijayan wrote:

          do i need to save it to a temporary location to convert it to bytes

          File.ReadAllBytes[^] will give you bytes of a file. I'd suggest to please avoid txtspeak[^] when you post messages. It is not readable. :)

          Navaneeth How to use google | Ask smart questions

          1 Reply Last reply
          0
          • V Vivek Vijayan

            m doin an applciation- file sending thru socket- i think its send as bytes.but wht funcitoon i can use to send it. do i need to save it to a temporary location to convert it to bytes can any one help me

            This code was posted by me...

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Vivek Vijayan wrote:

            do i need to save it to a temporary location to convert it to bytes

            Huh?! A file is already made of bytes. What conversion are you talking about? :confused:

            It is a crappy thing, but it's life -^ Carlo Pallini

            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