c# - How do I reproduce a DirectoryNotFoundException? -
i have problem using phantom delete , copy recursively. have solved actual problem quite easy checking below exception can tell me how reproduce problem visual studio?
system.io.directorynotfoundexception: not find part of path 'build/webui\views/web.config'. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ system.io.file.internalcopy(string sourcefilename, string destfilename, boolean overwrite) @ phantom.core.wrappedfileinfo.copytodirectory(string path) in d:\opensource\build\phantom2\phantom\src\phantom.core\wrappedfileinfo.cs:line 75 @ build.$$execute$closure$23$closure$25.invoke(wrappedfilesysteminfo file) @ phantom.core.builtins.utilityfunctions.foreach[t](ienumerable
1 source, action
1 action) in d:\opensource\build\phantom2\phantom\src\phantom.core\builtins\utilityfunctions.cs:line 34 @ build.$execute$closure$23.invoke()
@ phantom.core.target.execute() in d:\opensource\build\phantom2\phantom\src\phantom.core\target.cs:line 81 @ phantom.core.scriptmodel.executetargets(string[] targetnames) in d:\opensource\build\phantom2\phantom\src\phantom.core\scriptmodel.cs:line 73 @ phantom.program.execute(string[] args) in d:\opensource\build\phantom2\phantom\src\phantom\program.cs:line 57
the problem phantom started .bat/.cmd file , build file sent argument , fails somehow on windows 7 x64 machine doing exact same thing within visual studio 2008 works if copy views folder can recursively. original code (that fails command line):
public override void copytodirectory(string path) { if (!directory.exists(path)) { directory.createdirectory(path); } if (flatten) { var combinedpath = path.combine(path, name); file.copy(fullname, combinedpath, true); } else { var combinedpath = path.combine(path, pathwithoutbasedirectory); file.copy(fullname, combinedpath, true); } }
changing above to:
public override void copytodirectory(string path) { if (!directory.exists(path)) { directory.createdirectory(path); } if (flatten) { var combinedpath = path.combine(path, name); file.copy(fullname, combinedpath, true); } else { var combinedpath = path.combine(path, pathwithoutbasedirectory); var newpath = path.getdirectoryname(combinedpath); if (!directory.exists(newpath)) { directory.createdirectory(newpath); } file.copy(fullname, combinedpath, true); } }
makes specific problem go away fine mean figuring out took couple of minutes trying reproduce problem or create failing test has taken quite few hours , i'd know why can't done or learn how :)
edit: reason extremely silly here goes. base directory in case "views" pathwithourbasedirectory equal "home/about.aspx" darn thing not work in cmd did work in visual studio. next thing know can't make run in visual studio either applied fix , tests turn green. still don't know why...
i'd know why
well - there several problems:
let's path "c:\foo\bar.txt" (where bar.txt text-file).
calling directory.createdirectory(path).
you try create directory "c:\foo\bar.txt". however, "is" file.
then, when creating file, combine path file name - result might "c:\foo\bar.txt\bar.txt". however, can not succeed.
Comments
Post a Comment