Разделение и объединение PST файлов
Contents
[
Hide
]
Разделение и объединение PST файлов
Aspose.Email API предоставляет возможность разделять один PST файл на несколько PST файлов желаемого размера. Он также может объединять несколько PST файлов в один PST файл. Операции как разделения, так и объединения PST могут быть отслежены путем добавления событий к этим операциям.
Разделение на несколько PST
Следующий код показывает, как разделить несколько PST.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C | |
System::String dataDir = RunExamples::GetDataDir_Outlook(); | |
try | |
{ | |
System::String dstSplit = dataDir + L"Chunks\\"; | |
// Convert.ToString("Chunks\\"); | |
// Delete the files if already present | |
{ | |
const System::ArrayPtr<System::String>& array_ = System::IO::Directory::GetFiles(dstSplit); | |
for (int i_ = 0; i_ < array_->Count(); ++i_) | |
{ | |
System::String file__1 = array_[i_]; | |
{ | |
System::IO::File::Delete(file__1); | |
} | |
} | |
} | |
{ | |
System::SharedPtr<PersonalStorage> personalStorage = PersonalStorage::FromFile(dataDir + L"Sub.pst"); | |
// The events subscription is an optional step for the tracking process only. | |
personalStorage->StorageProcessed.connect(PstSplit_OnStorageProcessed); | |
personalStorage->ItemMoved.connect(PstSplit_OnItemMoved); | |
// Splits into pst chunks with the size of 5mb | |
personalStorage->SplitInto(5000000, dataDir + L"\\Chunks\\"); | |
} | |
} | |
catch (System::Exception& ex) | |
{ | |
System::Console::WriteLine(ex.get_Message() + L"\nThis example will only work if you apply a valid Aspose Email License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); | |
} | |
Объединение в один PST
Следующий код показывает, как объединить в один PST.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For complete examples and data files, please go to https://github.com/kashifiqb/Aspose.Email-for-C | |
// The path to the File directory. | |
System::String dataDir = RunExamples::GetDataDir_Outlook(); | |
System::String dst = dataDir + L"Sub.pst"; | |
totalAdded = 0; | |
try | |
{ | |
{ | |
System::SharedPtr<PersonalStorage> personalStorage = PersonalStorage::FromFile(dst); | |
// The events subscription is an optional step for the tracking process only. | |
personalStorage->StorageProcessed.connect(PstMerge_OnStorageProcessed); | |
personalStorage->ItemMoved.connect(PstMerge_OnItemMoved); | |
// Merges with the pst files that are located in separate folder. | |
personalStorage->MergeWith(System::IO::Directory::GetFiles(dataDir + L"MergePST\\")); | |
System::Console::WriteLine(L"Total messages added: {0}", System::ObjectExt::Box<int32_t>(totalAdded)); | |
} | |
System::Console::WriteLine(System::Environment::get_NewLine() + L"PST merged successfully at " + dst); | |
} | |
catch (System::Exception& ex) | |
{ | |
System::Console::WriteLine(ex.get_Message() + L"\nThis example will only work if you apply a valid Aspose Email License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); | |
} | |
Объединение папок из другого PST
Следующий код показывает, как объединить папки из другого PST.