PortalHomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 File Server

Go down 
AuthorMessage
Vengeance
Coder
Coder


Posts : 11
Ultras : 11
Fame : 0
Join date : 2009-05-03

PostSubject: File Server   Sun May 03, 2009 8:31 pm

Going to use this for Auto-Updating, just have to finish the client.

GUI:
Spoiler:
 
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Net.Sockets;

namespace FileServer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string hostName = "127.0.0.1";
            string path = textBox1.Text;
            int port = Convert.ToInt32(textBox2.Text.ToString());


            label1.Text = "Status: Running";
            MessageBox.Show("Server is now running!");
            IPAddress localAddr = IPAddress.Parse(hostName);



            TcpListener tcpL = new TcpListener(localAddr, port);
            tcpL.Start();

            for (; ; )
            {
                Socket socket = tcpL.AcceptSocket();
                if (socket.Connected)
                {
                    SendFileToClient(socket);
                    socket.Close();
                }
            }


        }

        void SendFileToClient(Socket socket)
        {
            string path = textBox1.Text;
            NetworkStream netStream = new NetworkStream(socket);
            StreamWriter writer = new StreamWriter(netStream);



            FileStream fileStream = File.Open(path + "/Gunz.exe", FileMode.Open, FileAccess.Read, FileShare.Read);
            FileStream fileStream2 = File.Open(path + "/GunzLauncher.exe", FileMode.Open, FileAccess.Read, FileShare.Read);
            FileStream fileStream3 = File.Open(path + "/system.mrs", FileMode.Open, FileAccess.Read, FileShare.Read);

            StreamReader reader = new StreamReader(fileStream);
            StreamReader reader2 = new StreamReader(fileStream2);
            StreamReader reader3 = new StreamReader(fileStream3);

            string strReadLine = null;
            string strReadLine2 = null;
            string strReadLine3 = null;
            do
            {
                strReadLine = reader.ReadLine();
                strReadLine2 = reader2.ReadLine();
                strReadLine3 = reader3.ReadLine();

                if (strReadLine != null && strReadLine2 != null && strReadLine3 != null)
                {
                    writer.WriteLine(strReadLine);
                    writer.WriteLine(strReadLine2);
                    writer.WriteLine(strReadLine3);
                }

                writer.Flush();

            }
            while (strReadLine != null && strReadLine2 != null && strReadLine3 != null);
            writer.Close();
        }
           

        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox.Show("Remember to not include the last forward-slash in the path!");
        }
    }
}
Back to top Go down
View user profile
Solar
Head Developer
Head Developer
avatar

Posts : 66
Ultras : 77
Fame : 2
Join date : 2009-04-28

PostSubject: Re: File Server   Sun May 03, 2009 9:31 pm

Nice work.
Back to top Go down
View user profile
Tributized
Developer
Developer


Posts : 9
Ultras : 16
Fame : 1
Join date : 2009-04-27

PostSubject: Re: File Server   Sun May 03, 2009 11:15 pm

good job 0.0
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: File Server   

Back to top Go down
 
File Server
Back to top 
Page 1 of 1
 Similar topics
-
» So I got off my lazy ass and have my Minecraft server up again.
» Minecraft -GC's Own Server, Looking for buddys to play with, have 2 free accounts. Just Regular playing is Fine.
» SN Team Fortress 2 server?
» Slenderman Minecraft Role-play server
» How to set up a Minecraft LAN server with 1.3

Permissions in this forum:You cannot reply to topics in this forum
 :: Ultra GunZ Server // :: Development Zone //-
Jump to: