protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _client?.Dispose();
                }

                disposedValue = true;
            }
        }
Exemple #2
0
        public static void StartProcess(AmsNetId target, string path, string dir, string args)
        {
            byte[] Data = new byte[777];

            BitConverter.GetBytes(path.Length).CopyTo(Data, 0);
            BitConverter.GetBytes(dir.Length).CopyTo(Data, 4);
            BitConverter.GetBytes(args.Length).CopyTo(Data, 8);

            System.Text.Encoding.ASCII.GetBytes(path).CopyTo(Data, 12);
            System.Text.Encoding.ASCII.GetBytes(dir).CopyTo(Data, 12 + path.Length + 1);
            System.Text.Encoding.ASCII.GetBytes(args).CopyTo(Data, 12 + path.Length + 1 + dir.Length + 1);

            ReadOnlyMemory <byte> buffer = new ReadOnlyMemory <byte>(Data);

            using (AdsClient client = new AdsClient())
            {
                client.Connect(new AmsAddress(target, AmsPort.SystemService));
                client.Write(500, 0, buffer);
                client.Dispose();
            }
        }