-
September 6th, 2016, 08:04 PM
#1
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);
}
}
-
September 11th, 2016, 11:33 AM
#2
Re: WebRequestMethods.Ftp.UploadFile works , nor error, but
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.
-
September 15th, 2016, 04:29 PM
#3
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|