示例#1
0
        public void CreateNewFileWithRenameAttemptsExcessiveRenamesTest()
        {
            MockFileSystem mockFileSystem = new MockFileSystem();

            FileCreator.CreateNewFileWithRenameAttempts("D:\\fakepath\\namecollision.txt", mockFileSystem, 1);
            FileCreator.CreateNewFileWithRenameAttempts("D:\\fakepath\\namecollision.txt", mockFileSystem, 1);
        }
        private string ExportMessageAttachment(IMessageAttachment attachment, string attachmentExportDirectory)
        {
            string attachmentExportPath = Path.Combine(attachmentExportDirectory, attachment.OriginalFilename);
            string createdAttachmentExportPath;

            using (Stream attachmentOutputStream = FileCreator.CreateNewFileWithRenameAttempts(attachmentExportPath, _exportFileSystem, MaxRenameAttempts, out createdAttachmentExportPath))
            {
                _exportFileSystem.CopyFile(attachment.Path, attachmentOutputStream);
            }
            return(createdAttachmentExportPath);
        }
        private string PlaceIconFile(string exportDirectory, string outputFilename, Bitmap icon)
        {
            string iconPath = Path.Combine(exportDirectory, outputFilename);
            string finalIconPath;

            using (Stream iconDestinationStream = FileCreator.CreateNewFileWithRenameAttempts(iconPath, _exportFileSystem, MaxRenameAttempts, out finalIconPath))
            {
                icon.Save(iconDestinationStream, IconFormat);
            }

            return(finalIconPath);
        }
        private List <ExportError> DoConversationTextExport(IConversation conversation, IDisplayOptionsReadOnly displayOptions, string exportFilename, IAttachmentExportLocator exportLocator)
        {
            List <ExportError> exportErrors = new List <ExportError>();
            string             finalExportFilename;

            try
            {
                using (Stream exportFileStream = FileCreator.CreateNewFileWithRenameAttempts(exportFilename, _exportFileSystem, MaxRenameAttempts, out finalExportFilename))
                {
                    using (StreamWriter exportStreamWriter = new StreamWriter(exportFileStream, Encoding.UTF8))
                    {
                        WriteHeader(exportStreamWriter, conversation);
                        WriteConversationContents(exportStreamWriter, conversation, displayOptions, exportLocator);
                        WriteFooter(exportStreamWriter);
                    }
                }
            }
            catch (Exception ex)
            {
                exportErrors.Add(new ExportError(conversation, ex));
            }

            return(exportErrors);
        }