<property name="report.file" value="${basedir}/Report-${timestamp}.txt"/>
...
<exec spawn="true" executable="notepad.exe">
<exec
<param line="${report.file}"/>
</exec>
</exec>
After notepad.exe runs and shows the report, I tried to do a File > Save As, and got this error dialog:
It turns out that ${basedir} evaluated to the full path of my project's basedir, with backslashes (\). I was then appending a forward slash (/) and my file name. Apparently this confused notepad when it tried to open the Save As dialog.
I fixed it by using the built-in ${file.separator} property that Ant inherits from Java, so my path now only contains backslashes. My file name property now looks like this:
<property name="report.file" value="${basedir}${file.separator}Report-${timestamp}.txt"/>
Thanks for the write up. Helped me solve a similar problem. Running the command "notepad c:\\directory\\file.err" gives the same result, which is that the "file.err" will open correctly and then give you a Common Dialog error when you try to File->Save As. Changing the command to "notepad c:\directory\file.err" solves the problem.
ReplyDeleteThank you for this post. I was trying to reset our default HOSTS file and it kept giving me that same error for the Common Dialog. THANK YOU SO MUCH!
ReplyDelete