void ApplyTags( TagSet s, string filename ) { ShouldProcessReason reason; bool sprocess = ShouldProcess("Applying tags to file \"" + filename + "\"" , "Should-we modify \"" + filename + "\" to apply tags to it?" , "File modification confirmation" , out reason); if (!sprocess) return; try { var f = TagLib.File.Create(filename); s.InjectIn(f.Tag); f.Save(); if (passThru) WriteObject(s); } catch (TagLib.UnsupportedFormatException e) { var err = new ErrorRecord(e, "The format is unsupported by get-tags", ErrorCategory.InvalidArgument, filename); WriteError(err); } catch (System.IO.FileNotFoundException e) { var err = new ErrorRecord(e, "File doesn't exist", ErrorCategory.ResourceUnavailable, filename); WriteError(err); } catch (TagLib.CorruptFileException e) { var err = new ErrorRecord(e, "File is corrupted", ErrorCategory.InvalidData, filename); WriteError(err); } catch (Exception e) { WriteDebug(e.ToString()); } }