示例#1
0
        private void writeDoor43File(int chapterNum, string chapterText, string outDir, int padding, Chunks chunks)
        {
            // build file name
            var outFilePath = Path.Combine(outDir, chapterNum.ToString().PadLeft(padding, '0') + ".usfm");

            if (!string.IsNullOrEmpty(chapterText))
            {
                // apply chunks
                if (chapterNum == 0)
                {
                    chapterText = chapterText.Trim();
                }
                else if (chunks != null)
                {
                    chapterText = chunks.ApplyChunksToChapter(chapterNum, chapterText);
                }
            }

            // make sure file ends with new line
            if ((chapterNum > 0) && !chapterText.EndsWith(Environment.NewLine))
            {
                chapterText += Environment.NewLine;
            }

            // write file
            File.WriteAllText(outFilePath, chapterText);
        }