File Access denied exception while uploading a file in the FTP Server

I am developing an application which will be used to upload the user files in to a FTP server.
Files are getting uploaded from the developer system to the server without raising any exception
Application is developed in 2.0 and hosted in a windows 2003 server, am attaching the code.
While uploading a file from the client system, fallowing exception is raised.

System.UnauthorizedAccessException: Access to the path 'C:\Documents and Settings\kb\Desktop\ddddddd.ppt' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at System.Net.WebClient.OpenFileInternal(Boolean needsHeaderAndBoundary, String fileName, FileStream& fs, Byte[]& buffer, Byte[]& formHeaderBytes, Byte[]& boundaryBytes)
   at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
string strFTPURL = ConfigurationManager.AppSettings["FTPURL"];
string strFTPUserName = ConfigurationManager.AppSettings["FTPUserName"];
string strFTPPassword = ConfigurationManager.AppSettings["FTPPassword"];
System.Net.WebClient ftpClient = new System.Net.WebClient();
System.Net.NetworkCredential ftpCredentials = new System.Net.NetworkCredential(strFTPUserName, strFTPPassword);
ftpClient.Credentials = ftpCredentials;                
ftpClient.Proxy = null;
ftpClient.UploadFile(strFTPURL + strFileName, strSelectedFile);

Open in new window

Who is Participating?
praneethkavulaConnect With a Mentor Author Commented:
The client system does not have sufficient rights for aspnet to access the folder that contains the file to be uploaded.
try giving the same permissions (add "aspnet" to the security on the folder) that are present on the development server.
also are you sure the path is the same on the development server? i.e 'C:\Documents and Settings\kb\Desktop' ??? (except for the profile name i.e kb)

i doubt that!
cross check and let me know.
praneethkavulaAuthor Commented:
My Ftp server have installed in it, and the ASPNET account have full control on the FTP folder.
and ASPNET account has full access on the Web Application folder in deployment server.
string strFTPURL = "ftp://ftpserverIP/Uploads/";
Client selected the file from the file upload control is
"C:\Documents and Settings\kb\Desktop\ddddddd.ppt"
am changing the strFileName to
strFileName = "ddddddd.ppt"; using strFileName = Path.GetFileName(fuUploadFile.PostedFile.FileName);

so the destination file would be ftp://ftpserverIP/Uploads/ddddddd.ppt
and the source is "C:\Documents and Settings\kb\Desktop\ddddddd.ppt"

This application is live on internet so my client needs file uploading can be done from any where, so how can i set permissions on the client system.

is your application running under a specific account? try to get the user to upload the file from another location say from another drive.does it upload then? check your impersonation in configuration file.
try restarting your IIS once and check again. also, which permissions presently exist on the ftp?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.