Ftp Upload File
- This is my code snippet for file upload. The problem is after all the bytes are written on the server, while doing requestStream.Close() I get error as underlying connection was closed.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.UsePassive = false;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("xyz", "xyz");
Stream requestStream = request.GetRequestStream();
const int bufferLength = 2048;
byte[] buffer = new byte[bufferLength];
int count = 0;
int readBytes = 0;
FileStream stream = File.OpenRead(fileName);
do
{
readBytes = stream.Read(buffer, 0, bufferLength);
requestStream.Write(buffer, 0, readBytes);
count += readBytes;
}
while (readBytes != 0);
requestStream.Flush();
requestStream.Close();//get an error here. Also dont think I can avoid this //statement.
FtpWebResponse response = (FtpWebResponse)request.GetResponse(); response.Close();
I am using VS 2005 and the ftp server is Microsoft Ftp server.
Answers
This code worked for me and I didn't get any exceptions. I tried with a simple txt file in the current directory. Note: since you're using active ftp you have to set the proxy to null.
using
System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace FtpWebRequest_MSDN2
{
class Program
{
static void Main(string[] args)
{
string serverUri = ftp://yourIP/textFile.txt;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.UsePassive = false;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("user", "pass");
request.Proxy = null;
Stream requestStream = request.GetRequestStream();
const int bufferLength = 2048;
byte[] buffer = new byte[bufferLength];
int count = 0;
int readBytes = 0;
FileStream stream = File.OpenRead("textFile.txt");
do
{
readBytes = stream.Read(buffer, 0, bufferLength);
requestStream.Write(buffer, 0, readBytes);
count += readBytes;
}
while (readBytes != 0);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream respStream = response.GetResponseStream();
respStream.Close();
response.Close();
}
}
}This is just a sample without try-catch and any other checks to get you started. I've used as much of your code as I could to make it easier for you to find the problem. 90% of the time the problem with active ftp connections is that your firewall or antivirus software block the response from the server and when we don't receive it we consider the connection didn't succeed and throw an exception.
Mariya
All Replies
Does serverUri contain your filename as well? it has to be something like that serverUri=ftp://servername/path/fileName ?
Also, try commenting the line containing the Flush
Mariya
- the serverUri is right coz the file gets uploaded, I can stream that file and see...
Also commenting flush does not help.
Can this be a problem of server...I am using Microsoft Ftp Server. The reasons to receive "The Underlying Connection closed" exception can be quite different. Bad server configuration is just one of the possible reasons. Can you get a System.Net trace log and a netmon trace anf post them here?
Here are instructions on how to get a trace log and a netmon trace
http://blogs.msdn.com/dgorti/archive/2005/09/18/471003.aspx
http://blogs.msdn.com/dgorti/archive/2005/10/29/486887.aspxMariya
I tested your code on our FtpServers (by FtpServer I mean FtpService running under IIS) and it worked fine.
Since you're setting UsePassive to false it is very probable taht your firewall is blocking the connection coming from the ftp server. Try stopping the firewall and exceuting it again to see if it will work.
Mariya
- yeh, I will try that...sorry for late reply was on holiday for two days.
I will try the above two ways, lets see wat works... - this is the log that I get....
System.Net Verbose: 0 : [3260] WebRequest::Create(ftp://71.6.135.39/uservideos/Shri.wmv)
System.Net Information: 0 : [3260] FtpWebRequest#28068188::.ctor(ftp://71.6.135.39/uservideos/Shri.wmv)
System.Net Verbose: 0 : [3260] Exiting WebRequest::Create() -> FtpWebRequest#28068188
System.Net Verbose: 0 : [3260] FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3260] FtpWebRequest#28068188::GetRequestStream(Method=STOR.)
System.Net Information: 0 : [3260] Associating FtpWebRequest#28068188 with FtpControlStream#33163964
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [220 Microsoft FTP Service]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [USER piot]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [331 Password required for piot.]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [PASS ********]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [230-Piot FTP
230 User piot logged in.]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [OPTS utf8 on]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [501 option not supported]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [PWD]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [257 "/" is current directory.]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [CWD /uservideos/]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [250 CWD command successful.]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [TYPE I]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [200 Type set to I.]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [PORT 192,168,2,2,5,192]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [200 PORT command successful.]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Sending command [STOR Shri.wmv]
System.Net Information: 0 : [3260] FtpControlStream#33163964 - Received response [150 Opening BINARY mode data connection for Shri.wmv.]
System.Net Verbose: 0 : [3260] Exiting FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3260] FtpWebRequest#28068188::(Releasing FTP connection#33163964.) Is this the whole trace? According to what you have pasted here the connection is established just fine and I don't see any exceptions. Did you try stopping the firewall?
Mariya
- The last line in the Trace says Releasing....it is not released?
There is no mention 220 command which states Transfer complete. - This is trace while transfering a small file...basically the small and big files get transfered properly if the server is local, while on remote server it gives a problem.
System.Net Verbose: 0 : [3060] WebRequest::Create(ftp://71.6.135.39/uservideos/Sara.wmv)
System.Net Information: 0 : [3060] FtpWebRequest#28068188::.ctor(ftp://71.6.135.39/uservideos/Sara.wmv)
System.Net Verbose: 0 : [3060] Exiting WebRequest::Create() -> FtpWebRequest#28068188
System.Net Verbose: 0 : [3060] FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3060] FtpWebRequest#28068188::GetRequestStream(Method=STOR.)
System.Net Information: 0 : [3060] Associating FtpWebRequest#28068188 with FtpControlStream#33163964
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [220 AksTech FTP server ready...]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [USER piot]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [331 User piot okay, need password.]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [PASS ********]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [230-command ok
230 User logged in, proceed.]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [OPTS utf8 on]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [200 UTF8 OPTS ON]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [PWD]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [257 "/" is current directory.]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [CWD /uservideos/]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [250 /uservideos now current directory.]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [TYPE I]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [200 Command okay]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [PORT 192,168,2,2,7,137]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [200 Command okay]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Sending command [STOR Sara.wmv]
System.Net Information: 0 : [3060] FtpControlStream#33163964 - Received response [150 Status OK, about to open data connection.]
System.Net Verbose: 0 : [3060] Exiting FtpWebRequest#28068188::GetRequestStream()
System.Net Verbose: 0 : [3764] WebRequest::Create(ftp://71.6.135.39/uservideos/Sara.wmv)
System.Net Information: 0 : [3764] FtpWebRequest#28068188::.ctor(ftp://71.6.135.39/uservideos/Sara.wmv)
System.Net Verbose: 0 : [3764] Exiting WebRequest::Create() -> FtpWebRequest#28068188
System.Net Verbose: 0 : [3764] FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3764] FtpWebRequest#28068188::GetRequestStream(Method=STOR.)
System.Net Information: 0 : [3764] Associating FtpWebRequest#28068188 with FtpControlStream#33163964
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [220 AksTech FTP server ready...]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [USER piot]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [331 User piot okay, need password.]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [PASS ********]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [230-command ok
230 User logged in, proceed.]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [OPTS utf8 on]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [200 UTF8 OPTS ON]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [PWD]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [257 "/" is current directory.]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [CWD /uservideos/]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [250 /uservideos now current directory.]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [TYPE I]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [200 Command okay]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [PORT 192,168,2,2,7,139]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [200 Command okay]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Sending command [STOR Sara.wmv]
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [150 Status OK, about to open data connection.]
System.Net Verbose: 0 : [3764] Exiting FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3764] FtpControlStream#33163964 - Received response [226- command ok
226-Closing data connection.
226 - [Section: ALL] - [Free: 11.52 G] - [Dl: 1.02 M] - [Ul: 69.72 M] -]
System.Net Information: 0 : [3764] FtpWebRequest#28068188::(Releasing FTP connection#33163964.)
System.Net Verbose: 0 : [3764] FtpWebRequest#28068188::GetResponse()
System.Net Information: 0 : [3764] FtpWebRequest#28068188::GetResponse(Method=STOR.)
System.Net Verbose: 0 : [3764] Exiting FtpWebRequest#28068188::GetResponse()
System.Net Verbose: 0 : [3764] FtpWebResponse#14421545::Close()
System.Net Verbose: 0 : [3764] Exiting FtpWebResponse#14421545::Close() - The above one is succesfull transfer trace, while the below one is not:
System.Net Verbose: 0 : [3404] WebRequest::Create(ftp://71.6.135.39/uservideos/Shri1.wmv)
System.Net Information: 0 : [3404] FtpWebRequest#28068188::.ctor(ftp://71.6.135.39/uservideos/Shri1.wmv)
System.Net Verbose: 0 : [3404] Exiting WebRequest::Create() -> FtpWebRequest#28068188
System.Net Verbose: 0 : [3404] FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3404] FtpWebRequest#28068188::GetRequestStream(Method=STOR.)
System.Net Information: 0 : [3404] Associating FtpWebRequest#28068188 with FtpControlStream#33163964
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [220 AksTech FTP server ready...]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [USER piot]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [331 User piot okay, need password.]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [PASS ********]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [230-command ok
230 User logged in, proceed.]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [OPTS utf8 on]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [200 UTF8 OPTS ON]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [PWD]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [257 "/" is current directory.]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [CWD /uservideos/]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [250 /uservideos now current directory.]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [TYPE I]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [200 Command okay]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [PORT 192,168,2,2,7,152]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [200 Command okay]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Sending command [STOR Shri1.wmv]
System.Net Information: 0 : [3404] FtpControlStream#33163964 - Received response [150 Status OK, about to open data connection.]
System.Net Verbose: 0 : [3404] Exiting FtpWebRequest#28068188::GetRequestStream()
System.Net Information: 0 : [3404] FtpWebRequest#28068188::(Releasing FTP connection#33163964.) Looks like in the second case we never received the 220 and then we block releasing the connection. I'll investigate further and get back to you. Meanwhile, can you tell me if you have this problem in passive mode as well (set UsePassive to true instead of to false).
Also is your ftp server accessible from outside? Can I test on it? It will be easier to repro since we don't have AksTech FTP
Mariya
- Thanks for giving lot of your time....
I will mail you regarding the ftp server.
Tried with UsePassive = true but it gives an error stating "The sever returned an address in response to PASV that is different than the address to which ftp connection was made"
Thanks again. Got your e-mail and I am in the process of investigating the issue. I'll get back to you on Monday.
Thanks
MariyaThis code worked for me and I didn't get any exceptions. I tried with a simple txt file in the current directory. Note: since you're using active ftp you have to set the proxy to null.
using
System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
namespace FtpWebRequest_MSDN2
{
class Program
{
static void Main(string[] args)
{
string serverUri = ftp://yourIP/textFile.txt;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.UsePassive = false;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential("user", "pass");
request.Proxy = null;
Stream requestStream = request.GetRequestStream();
const int bufferLength = 2048;
byte[] buffer = new byte[bufferLength];
int count = 0;
int readBytes = 0;
FileStream stream = File.OpenRead("textFile.txt");
do
{
readBytes = stream.Read(buffer, 0, bufferLength);
requestStream.Write(buffer, 0, readBytes);
count += readBytes;
}
while (readBytes != 0);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream respStream = response.GetResponseStream();
respStream.Close();
response.Close();
}
}
}This is just a sample without try-catch and any other checks to get you started. I've used as much of your code as I could to make it easier for you to find the problem. 90% of the time the problem with active ftp connections is that your firewall or antivirus software block the response from the server and when we don't receive it we consider the connection didn't succeed and throw an exception.
Mariya
- Lets see how this goes...but wud have to make some changes because this did break again at same place..
- Minor detail: to simplify things you can read the whole file at one go with StreamReader.ReadToEnd.
Hi,
This also happens to me but only for large files (like >20MB).
Did you get any fix on this?
Regards,
Eduardo
The trace looks like you are using a numeric IP (71.6.135.39).
But if you are using a string name in serverUri, try using the numeric 71.6.135.39 and try toggling passive mode.
This happens sometimes, particularily with shared hosting.
James- Good afternoon Mariya,
I want to ask you about upload file into the FTP server.
The code you gave is very good and worked fine, but I found it does not work on .Net 1.1
Do you have any function that can work on Framework .Net 1.1?
I do appreciate very much your help
Thank you very much
Maan I'm not sure why it happens, but handling the FTP is quite different from server to server. I had an headache when developing my own FTP lib using .NET socket & FTPWebrequest, finally I decided to use this .NET FTP Component .
You should stop using the .NET FTP component from ComponentForge you are mentioning. In fact it's illegal. The ComponentForge have stolen that FTP component from Rebex and is not authorized to sell licenses to anyone. Moreover the ComponentForge scam site is down. I would recommend using the genuine Rebex FTP/SSL for .NET .
BTW - Oma Danny is recommending ComponentForge components in all his posts and tries to look like he is a independent third party. Something smells here. Isn't it an example of astroturfing ? Just another scam from ComponentForge?The code you gave is very good and worked fine, but I found it does not work on .Net 1.1
FtpWebRequest is supported on .NET 2.0 or later. If you need it in .NET 1.1 you have to use a third party component or to write your own. Following code uses Rebex FTP component which support .NET 1.0 and 1.1.
Do you have any function that can work on Framework .Net 1.1?
// create client, connect and log in Ftp client = new Ftp(); client.Connect("ftp.example.org"); client.Login("username", "password"); // upload the 'test.zip' file to the current directory at the server client.PutFile(@"c:\data\test.zip", "test.zip"); client.Disconnect();
- Hi,
Any can please reply my issues? Hallo Maria,
I coded for the FTP upload file, i am getting error message as The underlying connection was closed: The server committed a protocol violation.
My code as follows
FtpWebRequest
request = null;
FtpWebResponse response = null;FtpWebRequest) WebRequest.Create(FTPServerPath+Filename);
request.UsePassive = UsePassive;
request.Method = WebRequestMethods.Ftp.UploadFile ;
request.Credentials = new NetworkCredential(Username, Password);
request.Proxy = null;StreamReader streamReader = new StreamReader(UploadFileNamePath);
Byte[] fileContent = Encoding.UTF8.GetBytes(streamReader.ReadToEnd());
streamReader.Close();
streamReader.Dispose();Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContent, 0, fileContent.Length);
requestStream.Close();
requestStream.Dispose();response = (
FtpWebResponse) request.GetResponse()
Also please see my trace log information
System.Net Verbose: 0 : [4128] WebRequest::Create(ftp://ftp.example.com/ErrorPage.doc)
System.Net Information: 0 : [4128] FtpWebRequest#49907388::.ctor(ftp://ftp.example.com/ErrorPage.doc)
System.Net Verbose: 0 : [4128] Exiting WebRequest::Create() -> FtpWebRequest#49907388
System.Net Verbose: 0 : [4128] FtpWebRequest#49907388::GetRequestStream()
System.Net Information: 0 : [4128] FtpWebRequest#49907388::GetRequestStream(Method=STOR.)
System.Net.Sockets Verbose: 0 : [4128] Socket#31239962::Socket(InterNetwork#2)
System.Net.Sockets Verbose: 0 : [4128] Exiting Socket#31239962::Socket()
System.Net.Sockets Verbose: 0 : [4128] Socket#31239962::Connect(115:21#1933695062)
System.Net.Sockets Verbose: 0 : [4128] Exiting Socket#31239962::Connect()
System.Net Information: 0 : [4128] Associating FtpWebRequest#49907388 with FtpControlStream#63621045
System.Net.Sockets Verbose: 0 : [4128] Socket#31239962::Receive()
System.Net.Sockets Verbose: 0 : [4128] Data from Socket#31239962::Receive
System.Net.Sockets Verbose: 0 : [4128] 00000000 : :
System.Net.Sockets Verbose: 0 : [4128] Exiting Socket#31239962::Receive() -> 0#0
System.Net.Sockets Verbose: 0 : [4128] Socket#31239962::Dispose()
System.Net Information: 0 : [4128] FtpWebRequest#49907388::(Releasing FTP connection#63621045.)
System.Net Error: 0 : [4128] Exception in the FtpWebRequest#49907388::GetRequestStream - The underlying connection was closed: The server committed a protocol violation.
System.Net Error: 0 : [4128] at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.InvokeRequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetRequestStream()
System.Net Error: 0 : [4128] Exception in the
#28589617::UnhandledExceptionHandler - The underlying connection was closed: The server committed a protocol violation.
System.Net Error: 0 : [4128] at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.FtpWebRequest.RequestCallback(Object obj)
at System.Net.CommandStream.InvokeRequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetRequestStream()
at FileTransfer.FileTransferCls.FTPUploadFile(String Filename, String UploadFileNamePath) in C:\healthsmt\WindowsApp\FileTransfer\FileTransfer\FileTransferCls.cs:line 130
at FileTransfer.TransferFile.btnUploadFileToFTP_Click(Object sender, EventArgs e) in C:\healthsmt\WindowsApp\FileTransfer\FileTransfer\TransferFile.cs:line 156
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at FileTransfer.Program.Main() in C:\healthsmt\WindowsApp\FileTransfer\FileTransfer\Program.cs:line 17
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
System.Net Verbose: 0 : [4128] Exiting FtpWebRequest#49907388::GetRequestStream()
Please suggest me to fix this issue and thank you for your effort and time.request.EnableSsl = EnableSSL;
request.UseBinary = UseBinary;
request.KeepAlive = KeepAlive;request= (
I am sorry, by mistake i clicked Propose as answer, so this is my question please anyone answer me..

