本文整理汇总了C#中IContact.CommitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# IContact.CommitChanges方法的具体用法?C# IContact.CommitChanges怎么用?C# IContact.CommitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContact
的用法示例。
在下文中一共展示了IContact.CommitChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommitContact
public static HRESULT CommitContact(IContact contact, bool force)
{
Verify.IsNotNull<IContact>(contact, "contact");
HRESULT hr = contact.CommitChanges(ContactValue.CGD_DEFAULT);
// If this failed because of conflicting changes then try going directly to the file at the caller's behest.
if (force
&& ((HRESULT)Win32Error.ERROR_NESTING_NOT_ALLOWED == hr
|| (HRESULT)Win32Error.ERROR_FILE_NOT_FOUND == hr))
{
string path;
GetPath(contact, out path).ThrowIfFailed("Conflicting changes were encountered but an error occurred trying to bypass them.");
using (FileStream fstream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read))
{
using (ManagedIStream istream = new ManagedIStream(fstream))
{
((IPersistStream)contact).Save(istream, true);
hr = HRESULT.S_OK;
}
}
}
return hr;
}