Hi,
I am new to Solarwinds, and got task to create an application to upload files to SolarWind Webclient ftp server. I tried the following code in C#
Code
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpPath+"/"+ fileName);
request.Method = WebRequestMethods.Ftp.UploadFile;
// This example assumes the FTP site uses anonymous logon.
request.Credentials = new NetworkCredential(userName, password);
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(FileToCopy);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
//Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
result = true;
response.Close();
When I ran this I did not get any error, nor my files uploaded. I have Googled also, but all in vain,
Please help...
Clik here to view.
