tags:

views:

152

answers:

1

*I want to test the script have access to a particular file share using nant. so i started checking this by doing a simple file copy on to that share. this worked fine, but when the share do not have write permissions , script is crashing even though i have try catch because of System.UnauthorizedAccessException: Access to the path '\mypc\testsharefolder\systemaccesscheck.txt' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)*

kindly suggest me a way to get around this problem, or a script to check the access rights.

`<target name="test.target">
 <echo>start of try catch block</echo>
<trycatch>
<try>
<copy file="c:\systemaccesscheck.txt" todir="\\mypc\testsharefolder" overwrite="true"/>
<echo>filecopy passed</echo>
</try>
<catch property="failure">
<echo>inside catch block because of failure</echo>
</catch>
</trycatch>
<echo>End of try catch block</echo>`
A: 

Find out which user account is used to run the NAnt scripts, and then check that user account has permissions on the target folder that you're trying to copy to.

You could even try to log onto your PC using that account and manually trying to create a a new text file in the target folder.

Hope this helps.

Brett Rigby