how to send log file from one computer to another computer in c#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sekharopponnam
    New Member
    • Jan 2013
    • 3

    how to send log file from one computer to another computer in c#?

    Code:
    public partial class Loginform : Form
        {       
            public Loginform()
            {
                InitializeComponent();
            }
          
            private void btnlogin_Click(object sender, EventArgs e)
            {
                if (!Directory.Exists(("//CENSYS06/C:/chandu/abc.txt")))
                {
                    Directory.CreateDirectory("//CENSYS06/C:/chandu/abc.txt");
                }
    
                string dir = (("//CENSYS06/C:/chandu/abc.txt"));
    
                if (!File.Exists(dir))
                {
                    File.Create(dir);
                }
    
                string filePath = dir;
    
                string s = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
                string s1 = getIP();
    
                using (StreamWriter swrObj = new StreamWriter(filePath, true))
                {
                    swrObj.Write(s1 + "|" + s + "|" + Txtusername.Text + "|" + "user logged in on :|" + DateTime.Now.ToShortDateString() + " at " + DateTime.Now.ToShortTimeString());
    
                    swrObj.Write("\t\t");
    
                    swrObj.Write("\t\t");
    
                    swrObj.WriteLine();
    
                    MessageBox.Show("Login success");
                }
            }
    i am using c# wondows application i want to send log file from one computer another in c#,i am using above code not working?
    Last edited by Meetee; Jan 10 '13, 11:48 AM. Reason: Use code tags <code/> around code
  • adriancs
    New Member
    • Apr 2011
    • 122

    #2
    You can use client/server to send it.
    convert the file into byte[] from A (client)
    A send the byte[] to B.
    B (server) open a port and receives byte[] from A.
    B convert byte[] and write it into file.

    search tutorial of C# Client/Server in google.

    Comment

    Working...