WebRequestMethods.Ftp.UploadFile works , nor error, but
Does anyone have an idea whats wrong or whats left. I never got an error message, but the file is finally not in my webspace.
I search around, looking if this code needs something else, but there isnt.
Code:
private void btnDownloadTest_Click(object sender, EventArgs e)
{
string strPath = string.Empty;
FtpWebRequest reqFTP = null;
try
{
strPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
if (File.Exists(strPath + "\\MyCert.cer"))
{
strPath = Path.Combine(strPath, "MyCert.cer");
}
else
{
MessageBox.Show("File does not exist");
return;
}
FileStream myStream = new FileStream(strPath, FileMode.Open, FileAccess.Read, FileShare.Read);
reqFTP = (FtpWebRequest)WebRequest.Create("ftp://www.MyWebSpace.net//MyFolder//Subfolder");
reqFTP.EnableSsl = true;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.KeepAlive = false;
reqFTP.Credentials = new NetworkCredential("FtpUser", "FtpKeyword");
}
catch (IOException ex)
{
MessageBox.Show(ex.TargetSite + " " + ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.TargetSite + " " + ex.Message);
}
}
Re: WebRequestMethods.Ftp.UploadFile works , nor error, but
Quote:
Originally Posted by
pschulz
Does anyone have an idea whats wrong or whats left. I never got an error message, but the file is finally not in my webspace.
I search around, looking if this code needs something else, but there isnt.
Code:
private void btnDownloadTest_Click(object sender, EventArgs e)
{
string strPath = string.Empty;
FtpWebRequest reqFTP = null;
try
{
strPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
if (File.Exists(strPath + "\\MyCert.cer"))
{
strPath = Path.Combine(strPath, "MyCert.cer");
}
else
{
MessageBox.Show("File does not exist");
return;
}
FileStream myStream = new FileStream(strPath, FileMode.Open, FileAccess.Read, FileShare.Read);
reqFTP = (FtpWebRequest)WebRequest.Create("ftp://www.MyWebSpace.net//MyFolder//Subfolder");
reqFTP.EnableSsl = true;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.KeepAlive = false;
reqFTP.Credentials = new NetworkCredential("FtpUser", "FtpKeyword");
}
catch (IOException ex)
{
MessageBox.Show(ex.TargetSite + " " + ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.TargetSite + " " + ex.Message);
}
}
Is the path valid?
Code:
"ftp://www.MyWebSpace.net//MyFolder//Subfolder"
Looks like it contains some extra forward slashes.
Re: WebRequestMethods.Ftp.UploadFile works , nor error, but
If I use any custom tool to upload or download a file to my webspace, it goes.