Problem in Fileupload With Ftp

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top