8.5.7.2 SecureDELTA SDK C# .NET Demo App


   SecureDELTA SDK CSharp Client Form Application file


The listing for MainSDDemoAppClientForm_x86.cs


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
//////////////////////////////////////////////////////////////////////
//                                                                     
// SecureDELTA SDK CSharp DEMO Application (32bit)                     
// Part of SecureDELTA SDK v2.56.109 (C) agersoftware srl              
//                                                                     
// Designed, developed and implemented by agersoftware srl and its     
// technology partner, NetLUP Xtreme Technologies srl                  
//                                                                     
// Copyright (C) 2019-2029 agersoftware srl, All Rights Reserved.      
// Portions Copyright (C) 2019-2029 NetLUP Xtreme Technologies srl.    
//                                                                     
// NOTICE:                                                             
// All information contained herein is, and remains the property of    
// agersoftware srl and its suppliers or technological partners,       
// especially NetLUP Xtreme Technologies srl                           
//                                                                     
// INTELLECTUAL PROPERTY                                               
// The intellectual and technical concepts contained herein are also   
// proprietary to agersoftware srl and its suppliers or technological  
// partners, especially NetLUP Xtreme Technologies srl and are         
// protected by trade secret or copyright law.                         
//                                                                     
// CONFIDENTIAL                                                        
// Dissemination of this information or reproduction of this material  
// is strictly forbidden unless prior written permission is obtained   
// from agersoftware srl or NetLUP Xtreme Technologies srl.            
//                                                                     
// COPYRIGHT                                                           
// This software is provided by the copyright holders and technology   
// partners "as is" and any express or implied warranties, including,  
// but not limited to, the implied warranties of merchantability and   
// fitness for a particular purpose are disclaimed.                    
//                                                                     
// NO LIABILITY                                                        
// In no event shall the copyright owner or technology partners be     
// liable for any direct, indirect, incidental, special, exemplary, or 
// consequential damages(including, but not limited to, procurement    
// of  substitute goods or services; loss of use, data, or profits;    
// or business interruption) however caused and on any theory of       
// liability, whether in contract, strict liability, or tort           
// (including negligence or otherwise)  arising in any way out of the  
// use of this software, even if advised of the possibility of such    
// damage.                                                             
//                                                                     
// INFO & CONTACT                                                      
// securesdk@securedelta.eu | securesdkinfo@agersoftware.com           
//                                                                     
///////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;

using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApp1
{
    public partial class MainSDDemoAppClientForm : Form
    {
        private string m_valueTextSourceFile;        // Initial or Source file full path. Old file. 
        private string m_valueTextTargetFile;        // Destination or Target file full path. New file.
        private string m_valueTextSecureDELTAFile;   // SecureDelta file full path
        private string m_valueTextPublicKeyFile;     // Distributed PublicKEY file full path. 

        private bool m_bCheckedXtreme = false;

        private const Int32 SECURE_DECODE_PRIORITY_CLASS_RT = 0x00;
        private const Int32 SECURE_DECODE_PRIORITY_CLASS_HIGH = 0x01;
        private const Int32 SECURE_DECODE_PRIORITY_CLASS_ABOVE = 0x02;
        private const Int32 SECURE_DECODE_PRIORITY_CLASS_NORMAL = 0x03;
        private const Int32 SECURE_DECODE_PRIORITY_CLASS_BELOW = 0x04;

        private const Int32 SD_SDK_ENCODE_NO_ERROR_ = 0x00;
        private const Int32 SD_SDK_DECODE_NO_ERROR_ = 0x00;

        private const Int32 _SD_SDK_MAXPATH_ = 0x17C;
        private const Int32 _SD_SDK_MAX_VER_ = 0x20;

        private const Int32 m_array_path_len = _SD_SDK_MAXPATH_ * sizeof(UInt16);
        private const Int32 m_array_ver_len = _SD_SDK_MAX_VER_ * sizeof(UInt16);

        private string cs_SecureDELTA_extention = ".SecureDELTA";
        private string cs_XtremeDELTA_extention = ".XtremeDELTA";

        private string cs_SD_SDK_SECURE_ENCODE_DLL_NAME = "SecureENCODE_SDK_DLL_x86.dll";
        private string cs_SD_SDK_SECURE_DECODE_DLL_NAME = "SecureDECODE_SDK_DLL_x86.dll";

        private string cs_SD_SDK_SECURE_ENCODE_MainFnct = "SecureDELTA_SDK_SecureENCODE_Main_"; // use @ to preserve quotes
        private string cs_SD_SDK_SECURE_DECODE_MainFnct = "SecureDELTA_SDK_SecureDECODE_Main_";

        private IntPtr m_hEncodeDll_x86 = IntPtr.Zero;
        private IntPtr m_hDecodeDll_x86 = IntPtr.Zero;


        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern IntPtr LoadLibrary(string dllToLoad);

        [DllImport("kernel32.dll")]
        public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName);

        [DllImport("kernel32.dll")]
        public static extern bool FreeLibrary(IntPtr hModule);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        private static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)]string lParam);
        const int EM_SETCUEBANNER = 0x1501;

        public static string TruncateString(string source, int length)
        {
            if (source.Length > length) {
                source = source.Substring(0, source.Length - length);
            }
            return source;
        }

        //For more documentation, please visit https://docs.microsoft.com/en-us/dotnet/framework/interop/default-marshaling-for-strings

        // SecureENCODE CALLBACK Definitions
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
        public unsafe struct SD_SDK_SECURE_ENCODE_CALLBACK_STRUCT
        {
            public UInt32 _callback_ID;
            public UInt32 _callback_event_type_ID;
            public Double dbl_operation_progress_indicator;
            public UInt32 uint_main_progress_indicator;
        };

        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
        public delegate Int32 SecureDELTA_SDK_SecureENCODE_Callback_Main_(SD_SDK_SECURE_ENCODE_CALLBACK_STRUCT _encode_struct, IntPtr p_user_data);

        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
        public unsafe struct SD_SDK_SecureENCODE_Struct
        {
            public byte _use_xtreme_mode;
            public byte _use_callback;
            public byte _use_high_cpu_priority;
            public byte _reserved_1;

            public UInt32 _reserved_2;

            public UInt32 _dwSourceMajorFileVersion;
            public UInt32 _dwSourceMinorFileVersion;
            public UInt32 _dwTargetMajorFileVersion;
            public UInt32 _dwTargetMinorFileVersion;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_sourcefile_path;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_targetfile_path;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_securedelta_path;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_ver_len)]
            public byte[] _wchr_versionSource;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_ver_len)]
            public byte[] _wchr_versionTarget;

            public IntPtr _callback_function_p_user_data;
            public IntPtr _callback_user_hwnd;
            public SecureDELTA_SDK_SecureENCODE_Callback_Main_ _secureencode_callback_function; // callback function
        };

        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
        private delegate Int32 SecureDELTA_SDK_SecureENCODE_Main_(ref SD_SDK_SecureENCODE_Struct _encode_struct);

        // SecureDECODE CALLBACK Definitions
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
        public unsafe struct SD_SDK_SECURE_DECODE_CALLBACK_STRUCT
        {
            public UInt32 _callback_ID;
            public UInt32 _callback_event_type_ID;
            public Double dbl_operation_progress_indicator;
            public UInt32 uint_main_progress_indicator;
        };

        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
        public delegate Int32 SecureDELTA_SDK_SecureDECODE_Callback_Main_(SD_SDK_SECURE_DECODE_CALLBACK_STRUCT _decode_struct, IntPtr p_user_data, UIntPtr _caller_HWnd);

        // SecureDECODE Structure Definitions
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 8)]
        public unsafe struct SD_SDK_SecureDECODE_Struct
        {
            public byte _use_callback;
            public byte _cpu_priority_level;
            public byte _reserved_1;
            public byte _reserved_2;
            public UInt32 _reserved_3;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_sourcefile_path;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_targetfile_path;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_securedelta_path;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = m_array_path_len)]
            public byte[] _wchr_publickey_path;

            public IntPtr _callback_function_p_user_data; // user specific data
            public IntPtr _callback_user_hwnd; // owner HWND
            public SecureDELTA_SDK_SecureDECODE_Callback_Main_ _securedecode_callback_function; // callback function
        };

        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
        private delegate Int32 SecureDELTA_SDK_SecureDECODE_Main_(ref SD_SDK_SecureDECODE_Struct _decode_struct);

        public Int32 _securedelta_sdk_secureencode_callback_(SD_SDK_SECURE_ENCODE_CALLBACK_STRUCT _encode_struct, IntPtr p_user_data)
        {
            progressBar_currentAction.Value = (Int32)_encode_struct.dbl_operation_progress_indicator;
            progressBar_mainAction.Value = (Int32)_encode_struct.uint_main_progress_indicator;
            return SD_SDK_ENCODE_NO_ERROR_;
        }

        public Int32 _securedelta_sdk_securedecode_callback_(SD_SDK_SECURE_DECODE_CALLBACK_STRUCT _decode_struct, IntPtr p_user_data, UIntPtr _caller_HWnd)
        {
            progressBar_currentAction.Value = (Int32)_decode_struct.dbl_operation_progress_indicator;
            progressBar_mainAction.Value = (Int32)_decode_struct.uint_main_progress_indicator;
            return SD_SDK_DECODE_NO_ERROR_;
        }

        public MainSDDemoAppClientForm()
        {
            InitializeComponent();

            SendMessage(textBox_editSourceFileName.Handle, EM_SETCUEBANNER, 1, "Please enter source file path or press browse to pick a file...");
            SendMessage(textBox_editTargetFileName.Handle, EM_SETCUEBANNER, 1, "Please enter target file path or press browse to pick a file...");
            SendMessage(textBox_editDeltaFileName.Handle,  EM_SETCUEBANNER, 1, "Please enter SecureDELTA(TM) file name...");

            m_hEncodeDll_x86 = LoadLibrary(cs_SD_SDK_SECURE_ENCODE_DLL_NAME);
            m_hDecodeDll_x86 = LoadLibrary(cs_SD_SDK_SECURE_DECODE_DLL_NAME);

            if ((m_hEncodeDll_x86 == IntPtr.Zero) || (m_hDecodeDll_x86 == IntPtr.Zero))
            {
                // Please note that in C#, because the backslash (\) is an escape character, 
                // literal backslashes in a string must be escaped or the entire string must be @-quoted.
                string title = @"Current Folder: " + Environment.CurrentDirectory;
                string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
                MessageBox.Show(title + "\nGetLastError returned: " + errorMessage, "GetLastError...", 0);
            }

            string statusEncodeDLL = "";
            string statusDecodeDLL = "";

            statusEncodeDLL = cs_SD_SDK_SECURE_ENCODE_DLL_NAME + ((m_hEncodeDll_x86 == IntPtr.Zero) ? "<not>" : "") + " loaded successfuly!";
            statusDecodeDLL = cs_SD_SDK_SECURE_DECODE_DLL_NAME + ((m_hDecodeDll_x86 == IntPtr.Zero) ? "<not>" : "") + " loaded successfuly!";

            labelSecureENCODE_status.Text = statusEncodeDLL;
            labelSecureDECODE_status.Text = statusDecodeDLL;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            m_valueTextTargetFile = textBox_editTargetFileName.Text;
            m_valueTextSecureDELTAFile = textBox_editTargetFileName.Text;
            textBox_editDeltaFileName.Text = m_valueTextSecureDELTAFile += cs_SecureDELTA_extention;
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
        }

        private unsafe void buttonSecureENCODE_Click(object sender, EventArgs e)
        {
            m_valueTextSourceFile = textBox_editSourceFileName.Text;
            m_valueTextTargetFile = textBox_editTargetFileName.Text;
            m_valueTextSecureDELTAFile = textBox_editDeltaFileName.Text;

            if ((m_valueTextSourceFile == "") || (m_valueTextTargetFile == "") || (m_valueTextSecureDELTAFile == ""))
            {
                MessageBox.Show("Missing one or more input file(s)!", "FATAL Error!");
                return;
            }

            if (m_hEncodeDll_x86 == IntPtr.Zero)
            {
                string message = "Missing SecureENCODE(TM) DLL?";
                string title = "Error";
                MessageBox.Show(message, title);
                return;
            }

            IntPtr ipSD_EncodeMain = GetProcAddress(m_hEncodeDll_x86, cs_SD_SDK_SECURE_ENCODE_MainFnct);// @"...");
            if (ipSD_EncodeMain == IntPtr.Zero)
            {
                string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
                string title = "Missing SecureENCODE(TM) DLL Main Proc Addresse(s)!" + "\nGetLastError returned: " + errorMessage;
                MessageBox.Show(title, "Error...", 0);
                return;
            }

            SD_SDK_SecureENCODE_Struct _encode_struct = new SD_SDK_SecureENCODE_Struct();

            {
                Encoding unicode = new UnicodeEncoding();

                _encode_struct._use_xtreme_mode = 0x00;

                _encode_struct._wchr_sourcefile_path = unicode.GetBytes(m_valueTextSourceFile);
                _encode_struct._wchr_targetfile_path = unicode.GetBytes(m_valueTextTargetFile);
                _encode_struct._wchr_securedelta_path = unicode.GetBytes(m_valueTextSecureDELTAFile);

                _encode_struct._wchr_versionSource = unicode.GetBytes("v1.101.200");
                _encode_struct._wchr_versionTarget = unicode.GetBytes("v1.100.100");

                SecureDELTA_SDK_SecureENCODE_Main_ _encode_main_proc = (SecureDELTA_SDK_SecureENCODE_Main_)Marshal.GetDelegateForFunctionPointer(ipSD_EncodeMain, typeof(SecureDELTA_SDK_SecureENCODE_Main_));

               try
               {
                    // Ensure SecureENCODE structure has proper MARSHALLING size
                    Array.Resize(ref _encode_struct._wchr_sourcefile_path, m_array_path_len);
                    Array.Resize(ref _encode_struct._wchr_targetfile_path, m_array_path_len);
                    Array.Resize(ref _encode_struct._wchr_securedelta_path, m_array_path_len);

                    Array.Resize(ref _encode_struct._wchr_versionSource, m_array_ver_len);
                    Array.Resize(ref _encode_struct._wchr_versionTarget, m_array_ver_len);

                    SecureDELTA_SDK_SecureENCODE_Callback_Main_ _encode_callback_proc = new SecureDELTA_SDK_SecureENCODE_Callback_Main_(_securedelta_sdk_secureencode_callback_);

                    _encode_struct._use_xtreme_mode = (m_bCheckedXtreme == true) ? (byte)0x01 : (byte)0x00;

                    _encode_struct._use_callback = 0x01;
                    _encode_struct._callback_function_p_user_data = IntPtr.Zero;
                    _encode_struct._secureencode_callback_function = _encode_callback_proc;
                    _encode_struct._callback_user_hwnd = Handle;

                    Int32 result = _encode_main_proc(ref _encode_struct);

                    string message = "SecureENCODE(TM) return code: " + result;
                    string title = "SecureENCODE(TM) result";
                    MessageBox.Show(message, title);
                }
                catch(System.Runtime.InteropServices.COMException exceptVar)
                {
                    string message = "Exception text: " + exceptVar.Message;
                    string title = "Exception raised during SecureENCODE!";
                    MessageBox.Show(message, title);
                };
            }
        }

        private unsafe void buttonSecureDECODE_Click(object sender, EventArgs e)
        {
            m_valueTextSourceFile = textBox_editSourceFileName.Text;
            m_valueTextTargetFile = textBox_editTargetFileName.Text;
            m_valueTextSecureDELTAFile = textBox_editDeltaFileName.Text;
            m_valueTextPublicKeyFile = textBox_editPublicKeyPath.Text;

            if ((m_valueTextSourceFile == "") || (m_valueTextTargetFile == "") || (m_valueTextSecureDELTAFile == ""))
            {
                string message = "Missing Input & Target file(s)!";
                string title = "Error";
                MessageBox.Show(message, title);
                return;
            }

            if (m_hDecodeDll_x86 == IntPtr.Zero)
            {
                string message = "Missing Decode DLL(s)?";
                string title = "Error";
                MessageBox.Show(message, title);
                return;
            }

            IntPtr ipSD_DecodeMain = GetProcAddress(m_hDecodeDll_x86, cs_SD_SDK_SECURE_DECODE_MainFnct);

            if (ipSD_DecodeMain == IntPtr.Zero)
            {
                string message = "Missing Decode DLL Main Proc Addresse(s)!";
                string title = "Error";
                MessageBox.Show(message, title);
                return;
            }

            SD_SDK_SecureDECODE_Struct _decode_struct = new SD_SDK_SecureDECODE_Struct();

            {
                Encoding unicode = new UnicodeEncoding();

                _decode_struct._wchr_sourcefile_path = unicode.GetBytes(m_valueTextSourceFile);
                _decode_struct._wchr_targetfile_path = unicode.GetBytes(m_valueTextTargetFile);
                _decode_struct._wchr_securedelta_path = unicode.GetBytes(m_valueTextSecureDELTAFile);
                _decode_struct._wchr_publickey_path = unicode.GetBytes(m_valueTextPublicKeyFile);

                SecureDELTA_SDK_SecureDECODE_Main_ _decode_main_proc = (SecureDELTA_SDK_SecureDECODE_Main_)Marshal.GetDelegateForFunctionPointer(ipSD_DecodeMain, typeof(SecureDELTA_SDK_SecureDECODE_Main_));

                try
                {
                    // Ensure SecureDECODE structure has proper MARSHALLING size
                    Array.Resize(ref _decode_struct._wchr_sourcefile_path, m_array_path_len);
                    Array.Resize(ref _decode_struct._wchr_targetfile_path, m_array_path_len);
                    Array.Resize(ref _decode_struct._wchr_securedelta_path, m_array_path_len);
                    Array.Resize(ref _decode_struct._wchr_publickey_path, m_array_path_len);

                    SecureDELTA_SDK_SecureDECODE_Callback_Main_ _decode_callback_proc = new SecureDELTA_SDK_SecureDECODE_Callback_Main_(_securedelta_sdk_securedecode_callback_);

                    _decode_struct._use_callback = 0x01;
                    _decode_struct._callback_function_p_user_data = IntPtr.Zero;
                    _decode_struct._securedecode_callback_function = _decode_callback_proc;
                    _decode_struct._callback_user_hwnd = Handle;
                    _decode_struct._cpu_priority_level = SECURE_DECODE_PRIORITY_CLASS_ABOVE;

                    Int32 result = _decode_main_proc(ref _decode_struct);

                    string message = "SecureDECODE return code: " + result;
                    string title = "SecureDECODE result";
                    MessageBox.Show(message, title);
                }
                catch (System.Runtime.InteropServices.COMException exceptVar)
                {
                    string message = "Exception text: " + exceptVar.Message;
                    string title = "Exception raised during SecureDECODE!";
                    MessageBox.Show(message, title);
                };
            }
        }

        private void formClosing(object sender, FormClosingEventArgs e)
        {
            if (m_hEncodeDll_x86 != IntPtr.Zero)
                FreeLibrary(m_hEncodeDll_x86);

            if (m_hDecodeDll_x86 != IntPtr.Zero)
                FreeLibrary(m_hDecodeDll_x86);
        }

        private void onLinkClicked(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("http://agersoftware.com");
        }

        private void OnUseXtremeCompressionChkBoxClick(object sender, EventArgs e)
        {
            m_valueTextSecureDELTAFile = textBox_editDeltaFileName.Text;

            m_bCheckedXtreme = checkBoxUseXtreme.Checked;

            if (m_bCheckedXtreme)
            {
                if (m_valueTextSecureDELTAFile.EndsWith(cs_SecureDELTA_extention))
                    m_valueTextSecureDELTAFile = TruncateString(m_valueTextSecureDELTAFile, cs_SecureDELTA_extention.Length);

                if (!m_valueTextSecureDELTAFile.EndsWith(cs_XtremeDELTA_extention))
                    m_valueTextSecureDELTAFile += cs_XtremeDELTA_extention;
            }
            else
            {
                if (m_valueTextSecureDELTAFile.EndsWith(cs_XtremeDELTA_extention))
                    m_valueTextSecureDELTAFile = TruncateString(m_valueTextSecureDELTAFile, cs_XtremeDELTA_extention.Length);

                if (!m_valueTextSecureDELTAFile.EndsWith(cs_SecureDELTA_extention))
                    m_valueTextSecureDELTAFile += cs_SecureDELTA_extention;
            }

            textBox_editDeltaFileName.Text = m_valueTextSecureDELTAFile;
        }

        private void buttonBrowseForSourceFile_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;
            openFileDialog1.Title = "Browse for Initial File";
            openFileDialog1.ShowDialog();

            textBox_editSourceFileName.Text = openFileDialog1.FileName;
        }

        private void buttonBrowseForTargetFile_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;
            openFileDialog1.Title = "Browse for Target File";
            openFileDialog1.ShowDialog();

            textBox_editTargetFileName.Text = openFileDialog1.FileName;
        }

        private void buttonBrowseFor_SecureDELTA_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
            openFileDialog1.RestoreDirectory = true;
            openFileDialog1.CheckFileExists = true;
            openFileDialog1.CheckPathExists = true;
            openFileDialog1.Title = "Browse for SecureDELTA File";
            openFileDialog1.ShowDialog();

            textBox_editDeltaFileName.Text = openFileDialog1.FileName;
        }

        private void buttonBrowseForPublicKey_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                folderBrowserDialog1.Description = "Pick Public KEY Folder";
                textBox_editPublicKeyPath.Text = folderBrowserDialog1.SelectedPath;
            }
        }

    }
}