–returning the instance cast to the type
–null if not possible
–does not raise an exception
–null if not possible
–does not raise an exception
h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->
using Microsoft.Office.Interop.Outlook;
public static int CountOfUnreadMails()
{
Application OutlookApp = new Application();
NameSpace myMail = OutlookApp.GetNamespace("MAPI");
int unread = myMail.GetDefaultFolder(OlDefaultFolders.olFolderInbox).UnReadItemCount;
return unread;
}
public static bool UploadSingleFiles(string fileName,int candidateId,int resumeId)
{
try
{
string parentDir = string.Empty;
string candir = string.Empty;
string desPath = string.Empty;
FileInfo objfileInfo = new FileInfo(fileName);
parentDir = ClsConfigurations.ReadSetting("Folder");
candir = @"/" + parentDir + "/" + Convert.ToString(candidateId);
desPath = candir +"-" + Convert.ToString(resumeId) + objfileInfo.Extension;
CreateDirectory(candir);
objFTPCon.ServerDirectory = candir.Trim();
objFTPCon.UploadFile(fileName, desPath);
return true;
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
return false;
}
}
using System.Collections.Generic;
using System.Windows.Forms;
namespace naraayananProject.UserControl
{
public class CustomErrorProvider :ErrorProvider
{
public List<Control> GetControls()
{
return this.GetControls(this.ContainerControl);
}
public List<Control> GetControls(Control ParentControl)
{
List<Control> ret = new List<Control>();
if (!string.IsNullOrEmpty(this.GetError(ParentControl)))
ret.Add(ParentControl);
foreach (Control c in ParentControl.Controls)
{
List<Control> child = GetControls(c);
if (child.Count > 0)
ret.AddRange(child);
}
return ret;
}
}
}
public static CustomErrorProvider ErrProvider = new CustomErrorProvider();
public static bool ComboBoxErrorControl(ComboBox cmb, string message, TabPage tp)
{
if (!String.IsNullOrEmpty(cmb.Text))
{
ErrProvider.SetError(cmb, "");
}
else
{
ErrProvider.SetError(cmb, message);
}
object[] control = ErrProvider.GetControls(tp).ToArray();
if (control.Length > 0)
return false;
else
return true;
}