Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
my problem is how to receive file from clients and save file on server

here is my client code:

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace client
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
           ofd.ShowDialog();
           textBox1.Text = ofd.FileName;
}

        private void button2_Click(object sender, EventArgs e)
        {
            Stream Fs = File.OpenRead(textBox1.Text);
           Byte[] buffer = new Byte[Fs.Length];
         Fs.Read(buffer, 0, buffer.Length);
          TcpClient socket = new TcpClient("10.10.3.137", 10);
         NetworkStream nw = socket.GetStream();
        nw.Write(buffer, 0, buffer.Length);
        nw.Close();
        } 
        }
    }
Posted
Updated 28-Dec-12 2:14am
v4
Comments
bbirajdar 27-Dec-12 11:11am    
What do you mean by client PC? Are they connected by LAN or VPN ?
fahimmahbub 27-Dec-12 13:11pm    
yes they connected by LAN
fahimmahbub 27-Dec-12 14:02pm    
actually i mean client pc means other pc
fahimmahbub 27-Dec-12 14:00pm    
please give me another solution
ridoy 27-Dec-12 15:01pm    
do you prefer bluetooth connection?

Without server? No, if you mean the software server, whatever it is — FTP server, HTTP server, custom network server. Practically, this is the same as to ask "How can I transfer files from one client PC to another client PC, without a second PC?" :-)

—SA
 
Share this answer
 
Comments
bbirajdar 28-Dec-12 2:38am    
I think the best solution for him is to write the files to a DVD and then transfer to another PC. :)
Sergey Alexandrovich Kryukov 28-Dec-12 2:44am    
You are right; in a way, it will work even if the second PC is not available. It will be deferred transfer!
—SA
fahimmahbub 28-Dec-12 8:05am    
my problem is how to receive file from clients and save file on server
Sergey Alexandrovich Kryukov 28-Dec-12 12:38pm    
So? It depends on what do you want to run on it. Do you have access to both computers? Will you run any service software or build your own? It could be as simple as file sharing service and can be also FTP, HTTP, custom, or something else...
—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 27-Dec-12 22:49pm    
Did you pay attention for the words "without server"? :-)
Even though it's not quite clear what OP means by "server", I basically answered — please see.
—SA
fahimmahbub 28-Dec-12 8:03am    
my problem is how to receive file from clients and save file on server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900