开发者

How to send file to remote computer?

开发者 https://www.devze.com 2022-12-29 09:57 出处:网络
i can get file name via below codes. How can i send this file to remote computer. this remote computer ip: 192.168.2.105 also i can use 51124 port

i can get file name via below codes. How can i send this file to remote computer. this remote computer ip: 192.168.2.105 also i can use 51124 port

   class Program
    {
        static void Main(string[] args)
        {

            string[] dosyalarinYollari = System.IO.Directory.GetFiles(@"z:\20071008\1.2.392.200036.9116.2.6.1.48.1215563310.1191800303.305777\", "*.dcm", System.IO.SearchOption.AllDirectories);
            foreach (string s in dosyalarinYollari)
            {
                Console.Write(s+"\n");  // i ne开发者_JAVA百科ed to send tihs s file to remote machine
            }

            Console.ReadKey();
        }
    }


There isn't nearly enough information here to give you a definitive answer, but I can mention some approaches. There are many ways to transfer files between computers, each with pros and cons.

  • Windows file sharing. As mentined by GxG, if this is a Windows (or SMB) environment, and you had the necessary permissions, and file sharing was enabled, you could try \\ipaddress\share\filename.
  • If the remote machine is across the internet, or file sharing is not available, protocols such as FTP are designed for uploading files to a remote machine, but the remote machine will need to be running an FTP server. .Net has native support for FTP (since .Net 2.0)
  • You could roll your own listener that listens for connections on the target machine, and receives the binary file stream and writes it to disk.
  • If you can connect to the remote machine via SSH, you could look at making a SCP call to upload the file
  • If this is an environment with NFS shares (.e.g the remote machine is possibly a UNIX server) you could mount in NFS and copy.

Some solutions are easier than others. Some require the target machine to be running a server. Some are Windows only, Unix only, etc, etc.

Can you give us more information on your environment, why you need to do this, etc.


a simple File.Copy passing the location as @"\[ip][drive]$[folder]" is enough to send it to a remote computer if you have rights to log on to that computer.

i'm not really sure about the location string.

0

精彩评论

暂无评论...
验证码 换一张
取 消