System.Net.Mail.SmtpClient.GetFileMailWriter C# (CSharp) Method

GetFileMailWriter() private method

private GetFileMailWriter ( string pickupDirectory ) : System.Net.Mail.MailWriter
pickupDirectory string
return System.Net.Mail.MailWriter
        internal MailWriter GetFileMailWriter(string pickupDirectory)
        {
            if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"{nameof(pickupDirectory)}={pickupDirectory}");

            if (!Path.IsPathRooted(pickupDirectory))
                throw new SmtpException(SR.SmtpNeedAbsolutePickupDirectory);
            string filename;
            string pathAndFilename;
            while (true)
            {
                filename = Guid.NewGuid().ToString() + ".eml";
                pathAndFilename = Path.Combine(pickupDirectory, filename);
                if (!File.Exists(pathAndFilename))
                    break;
            }

            FileStream fileStream = new FileStream(pathAndFilename, FileMode.CreateNew);
            return new MailWriter(fileStream);
        }