My project is simple desktop application.
I want to transfer(upload) a file from my desktop to
the another machine which is server of my machine.(One machine to another )
There is nothing to do with web service.
Can anybody send me help ?

Thanks in advance.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {

        public static void Main()
        {
            string sourcepath = @"c:\MyTest.txt";
            string path2 = @"\\10.2.55.184\Share\Team\Jitinder\MyTest.txt";

            try
            {
                // Create the file and clean up handles.


                // Ensure that the target does not exist.
                //File.Delete(path2);

                // Copy the file.
                File.Copy(sourcepath, path2,true);
                Console.WriteLine("{0} copied to {1}", sourcepath, path2);

            //    // Try to copy the same file again, which should succeed.
            //    File.Copy(sourcepath, path2, true);
            //    Console.WriteLine("The second Copy operation succeeded, which was expected.");
            //
            }

            catch
            {
                Console.WriteLine("Double copy is not allowed, which was not expected.");
            }


        }
    }
}

make sure u can access \\10.2.55.184\Share\Team\Jitinder\

u can directly do from explorer also

Edited 3 Years Ago by mike_2000_17: Fixed formatting

start quote:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {

        public static void Main()
        {
            string sourcepath = @"c:\MyTest.txt";
            string path2 = @"\\10.2.55.184\Share\Team\Jitinder\MyTest.txt";

            try
            {
                // Create the file and clean up handles.


                // Ensure that the target does not exist.
                //File.Delete(path2);

                // Copy the file.
                File.Copy(sourcepath, path2,true);
                Console.WriteLine("{0} copied to {1}", sourcepath, path2);

            //    // Try to copy the same file again, which should succeed.
            //    File.Copy(sourcepath, path2, true);
            //    Console.WriteLine("The second Copy operation succeeded, which was expected.");
            //
            }

            catch
            {
                Console.WriteLine("Double copy is not allowed, which was not expected.");
            }


        }
    }
}

make sure u can access \\10.2.55.184\Share\Team\Jitinder\

u can directly do from explorer also

Thanks jinus
it's working with slight changes

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This question has already been answered. Start a new discussion instead.