private void cmdUploadExcel_Execute(object obj) { try { string fileName = string.Empty; string safeFileName = string.Empty; // Initialize an OpenFileDialog OpenFileDialog openFileDialog = new OpenFileDialog(); // Set filter and RestoreDirectory openFileDialog.RestoreDirectory = true; openFileDialog.Filter = "Excel documents(*.xlsx)|*.xlsx"; bool?result = openFileDialog.ShowDialog(); if (result == true && openFileDialog.FileName.Length > 0) { fileName = openFileDialog.FileName; } if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) { return; } safeFileName = openFileDialog.SafeFileName; TupleOfstringstringboolean objTuple = pxyInvoice.UploadSheetUpdateDelete(IMSLibrary.Class.Helper.ConvertToByte(fileName.ToString()), safeFileName, Global.UserID, Const.InvoicingSheetType); ErrorFolder = objTuple.m_Item1; ErrorFile = objTuple.m_Item2; if (objTuple.m_Item3) { UIHelper.ShowMessage("File uploaded successfully!"); btnUpload = false; btnErrorFile = true; return; } UIHelper.ShowMessage("File not uploaded!"); } catch (FaultException ex) { UIHelper.ShowErrorMessage(ex.Message); } }