在大于2GB的文件中加入mp3

时间:2017-05-08 21:54:07

标签: c#

此方法有效,但生成的文件为> 2gb有一个错误:

    >System.IO.IOException: The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size.

        public static void CombineMp3InDirectory(string dir, string resultFilenameFullPath)
        {
            var mp3sList = new List<string>();
            var d        = new DirectoryInfo(dir);
            var infos    = d.GetFiles();

            foreach (FileInfo f in infos) { mp3sList.Add(f.FullName); }

            using (var w = new BinaryWriter(File.Create(resultFilenameFullPath)))
            {
                mp3sList.ForEach(f => w.Write(File.ReadAllBytes(f)));
            }
        }

    **UPDATE**
    Works now after changing setting  gcAllowVeryLargeObjects in App.xaml:
(thanks to FrankerZ's hint )

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <runtime>
        <gcAllowVeryLargeObjects enabled="true" />
      </runtime>
    </configuration>

0 个答案:

没有答案