Monday, July 2, 2012

Good Learning - 2 : UnauthorizedAccessException


First of all, apologies. This post can be pretty much useless as I dont remember the exact sequence of events, neither do I remember the exact lines of code that brought this error. 

But from what I remember, I was trying to access a file (file.copy or file.move, one of those) through C# script in SSIS, and I got this error.
system.io.__error.winioerror access denied

System.UnauthorizedAccessException: Access to the path '\\myserver\myfolder\mysubfolder' is denied. 

Well, the mistake I did was that I gave the path of the file without the actual file name.
So C# was trying to create a file with the same name as "mysubfolder" under "myfolder" which was obviously not allowed because it would be duplicates
.
The solution is to provide the path like this :
\\myserver\myfolder\mysubfolder\myfilename.txt
 or whatever the extension should be.

No comments:

Post a Comment