public static int Upload()

in SimpleDUTRemote/Functions.cs [523:554]


        public static int Upload(string path, bool overwrite, long port = 0)
        {
            // if the path to receive the file doesn't exist, try to create it.
            if (!Directory.Exists(path))
            {
                try {
                    Directory.CreateDirectory(path);
                }
                catch (Exception)
                {
                    throw new IOException($"Can't create receive directory {path}. " +
                    "There was either a permission problem, or the path is invalid."
                    );
                }
            }

            if (!ReadWriteChecks.CheckWriteToDir(path))
            {
                throw new IOException($"Can't write to {path}, there was either a permission problem or the path doesn't exist.");
            }
            TcpListener server = new TcpListener(IPAddress.Any, (int) port);

            // if a port is specified, use SO_REUSEADDR on the socket
            if (port != 0)
            {
                server.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            }

            server.Start(1);
            Task.Run(() => HelperFunctions.LargeFileTransfers.Upload(path, server, overwrite));
            return ((IPEndPoint)server.LocalEndpoint).Port;
        }