Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error- Configuration system failed to initialize

I got error on FtpWebRequest.Create(uri)

FileInfo fileInf = new FileInfo(FileName);
string uri = "ftp://" + ftpServerIP + "//";// +fileInf.Name;
FtpWebRequest reqFTP;

// Create FtpWebRequest object from the Uri provided
reqFTP = (FtpWebRequest)FtpWebRequest.Create(uri);

// Provide the WebPermission Credintials
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

// By default KeepAlive is true, where the control connection is
// not closed after a command is executed.
reqFTP.KeepAlive = false;

// Specify the command to be executed.
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

// Uploding work .....


How to resolve this problem
Posted
Updated 26-Oct-15 18:50pm
v2

1 solution

May be your file name already exists in FTP server please check properly.

Otherwise check below code.It will overwrite the existing File in FTP server.



string _FtpFilePath="ftp://198.XX.XX.YYYY//test1";
string _LocalFilePath="D:\\Dummy\\1234.xml";

WebClient FTP_Upload = new WebClient();
FTP_Upload.Credentials = new System.Net.NetworkCredential(_UserName, _Password);
FTP_Upload.UploadFile(_FtpFilePath + "/"+Path.GetFileName(_LocalFilePath),_LocalFilePath);
FTP_Upload.Dispose();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900