Advertisement

01.11.2008 at 02:18PM PST, ID: 23077135
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Webclient upload file to ftp server

Tags: c# net
FernandoSoto,
As I mentioned in another thread. I follow your code to upload a file to ftp server by webclient at my web application. I pass a file path to the function you posted. I got a exception 'An exception occurred during a WebClient request.' even trying to access my local develope machine which is set as ftp server also.

The code is:
private void UploadToFtp(string zpath)
{
      try
                  {
                        // String array to hold the full path of each file to be transfered
                        // to the FTP site.
                        string[] UploadFiles ={zpath}; // null;

                        // The web site URL
                        string remoteURI = "ftp://10.10.99.75/";
                        // Load files to this subdirectory
                        string placeFileInFolder ="NewStore/"; // "uploadfolder/";
                        // Create the FTP client
                        WebClient ftpClient = new WebClient();
                        // The user name and password are stored here
                        NetworkCredential nc = new NetworkCredential("mylog", "mypassword");
                        ftpClient.Credentials = nc;
                        // used to check if there were any errors in transfering the files
                        Exception err = null;

                        for (int idx = 0; idx < UploadFiles.Length; idx++)
                        {
                              // Call the function to transfer the files to the FTP site
                              err = xfer(ftpClient, remoteURI + placeFileInFolder, UploadFiles[idx]);
                              // Check to see if there were any errors in the transfer
                              if (err != null)
                              {
                                    // Write the error somewhere and reset err to null for the next transfer
                                    Response.Write(err.Message);
                                    err = null;
                              }
                        }
                  }
                  catch (Exception e)
                  {
                        myParam.Text="ERROR";
                        this.ERRMSG.Text=e.Message;
                  }
            }
        // client is the FTP client, remoteFile is where on the site the file will be
        // stored, localFile is the full path to the file going to be transfered
        // to the FTP site.
        private Exception xfer(WebClient client, string remoteFile, string localFile)
        {
            Exception retErr = null;
            // Get the file name from the local file to name the file on the remote
            string filename = Path.GetFileName(localFile);
            // Add the file name that the file will be called on the FTP site.
            string WebResources = remoteFile + filename;
            try
            {
                // Transfer the file to the FTP site.
                client.UploadFile(WebResources, localFile);
            }
            catch (Exception ex)
            {
                // If any errors occurred report it to the caller.
                retErr = ex;
            }
            return retErr;
        }      

Please help
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: lanac222
Solution Provided By: lanac222
Participating Experts: 2
Solution Grade: B
Views: 275
Translate:
Loading Advertisement...
01.11.2008 at 03:45PM PST, ID: 20641788

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 07:37AM PST, ID: 20653676

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 07:54AM PST, ID: 20653820

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 08:02AM PST, ID: 20653892

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 08:14AM PST, ID: 20654011

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 10:27AM PST, ID: 20655227

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 11:21AM PST, ID: 20655733

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.14.2008 at 06:07PM PST, ID: 20659489

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628