- Joined
- Jun 10, 2009
- Messages
- 1
- Reaction score
- 0
i have Asp.net page has fileupload it allow user to upload any file he want to web site ftp .
my problem is that my code work good in local in my pc but when i upload the web site it not work and show me error :
Could not find file 'C:\Documents and Settings\XPPRESP3\Desktop\New Folder (2)\test.zip'
the code that i used
and recive it in button by
i wish anyone can help me because i need help quickly
thanks to all
my problem is that my code work good in local in my pc but when i upload the web site it not work and show me error :
Could not find file 'C:\Documents and Settings\XPPRESP3\Desktop\New Folder (2)\test.zip'
the code that i used
Code:
private void Upload(string filename)
{
FileInfo fileInf = new FileInfo(filename);
string uri = "ftp://"+ftpServerIP+"/wwwroot/Program/"+ fileInf.Name;
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://"+ftpServerIP+"/wwwroot/Program/"+ fileInf.Name));
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.ContentLength = fileInf.Length;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
FileStream fs = fileInf.OpenRead();
try
{
Stream strm = reqFTP.GetRequestStream();
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
strm.Close();
fs.Close();
}
catch (Exception ex)
{
}
}
and recive it in button by
Code:
Upload(FileUpload1.PostedFile.FileName);
i wish anyone can help me because i need help quickly
thanks to all