i have console application built myself rename .mp3
files download. application has worked flawlessly quite few months, of sudden tossing titled exception @ me 1 particular directory. not 1 directory, happening on select number of files - 3 of them renamed.
here directory path , files:
here snippet of directory path exception thrown, along exception's message:
and here code:
static void main(string[] args) { string dir = @"m:\temp downloading folder"; var files = new directoryinfo(dir + @"\gregory alan isakov discography [2005 - 2013]\rust colored stones").getfiles("*.mp3").tolist(); foreach (var item in files) { if (item.name.substring(0, 2).all(char.isdigit)) { //string fullname = item.fullname.replace("\\", "/"); string newname = "gregory alan isakov "; //exception thrown here file.move(item.fullname, item.fullname.replace(item.name.substring(0, 3), newname)); } } console.writeline("done!"); console.readkey(); }
i tried changing path have /
instead of \\
same result.
according documentation on msdn:
the exception thrown when part of file or directory cannot found.
however, directory is found , correctly renamed first 3 files (as depicted in first image).
can explain me why happening?
you have bug in code changes folder instead of name of file, running code:
c:\temp downloading folder\gregory alan isakov discography [2005 - 2013]\rust colored stones\05 - ghosts.mp3
is changed to:
c:\temp downloading folder\gregory alan isakov discography [20gregory alan isakov - 2013]\rust colored stones\gregory alan isakov - ghosts.mp3
i let debug , fix yourself.
Comments
Post a Comment