0
我正在使用ID3lib和它們示例的MP3Lib(http://id3lib.sourceforge.net/) 當我編輯我的MP3時,它有時會起作用,有時候不起作用。然後我得到一個異常,該文件不能被重寫。這些文件未被使用。我認爲,問題是,我通過庫設置了ID3v2標籤,並且MP3可能只有ID3v1標頭? 有沒有人有過這樣的問題?使用新ID3保存MP3時出現問題標籤
編輯: 我設法找到問題,這發生在我試圖保存專輯的圖片時發生。
string filepath = Application.StartupPath + @"\temp.jpg";
if(File.Exists(filepath))
File.Delete(filepath);
FileStream fs = File.Create(filepath);
id3AlbumImage.Image.Save(fs, System.Drawing.Imaging.ImageFormat.Jpeg);
fs.Close();
using (FileStream stream = File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
byte[] buffer = new Byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
if (buffer != null)
{
MemoryStream memoryStream = new MemoryStream(buffer, false);
_mp3File.TagHandler.Picture = Image.FromStream(memoryStream);
}
}
的錯誤說: System.IO.IOException:被替換不能由文件覆蓋的文件移動。要被替換的文件保留其原始名稱。
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.__Error.WinIOError()
bei System.IO.File.Replace(String sourceFileName, String destinationFileName, String destinationBackupFileName, Boolean ignoreMetadataErrors)
bei Com.Hertkorn.Helper.Filesystem.FileMover.FileMove(FileInfo sourceLocation, FileInfo targetLocation, FileInfo backupLocation) in E:\Projects\id3lib\Mp3Lib\Utils\FileMover.cs:Zeile 51.
bei Mp3Lib.Mp3File.RewriteFile(FileInfo bakFileInfo) in E:\Projects\id3lib\Mp3Lib\MP3\Mp3File.cs:Zeile 346.
bei Mp3Lib.Mp3File.Update() in E:\Projects\id3lib\Mp3Lib\MP3\Mp3File.cs:Zeile 231.