I ran your code here pointing a server\share and it worked fine with or without using credentials...

I did however get an error the first time I tried, about connecting to the same share with multiple credentials. Once I changed the mapping to the IP of the server, then it worked fine. This may be the same issue you are having?