I am using an FTPClient library to transfer files from a windows share to an FTP server.
The SendFile method of the library uses the following code:
FileStream stream = new FileStream(localFileName, FileMode.Open);
This results in a System.UnauthorizedAccessException being thrown, however I am able to open, rename and move the file using windows explorer under the same user account which the code is being executed.
Can anyone tell me why this is happening?
Edit:
The strange thing is i can access other files on the share which have been granted the same NTFS permissions as the one that i can't.
This is also a windows forms app.
Update:
Still no luck with this, I am able to read the file using a StreamReader but not a file stream, I can't understand why the two behave differently.