C# Problem with WebRequestMethods

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rinoesc
    New Member
    • Feb 2009
    • 3

    #1

    C# Problem with WebRequestMethods

    Hello,

    I'm trying to create a ftp application for Windows Mobile.
    I'm using VisualStudio 2008 with OpenNETCF Framework for Windows Mobile.
    I have a problem with the following code...

    Code:
    string pathu = "ftp://10.0.1.100/florinpa/_desc.txt";
    MessageBox.Show("S-a definit pathu de conectare");
    Uri serveru = new Uri(@pathu);
    MessageBox.Show("S-a definit Uri");
    FtpWebRequest request = FtpWebRequest)FtpWebRequest.CreateDefault(serveru);
    MessageBox.Show("S-a definit requestu");
    request.Binary = true;
    MessageBox.Show("S-a definit request Binary");
    request.Credentials = new NetworkCredential("florinpa", "corcodel");
    MessageBox.Show("S-au definit credentialele");
    request.Method = WebRequestMethods.Ftp.DeleteFile;
    MessageBox.Show("S-a definit metoda");
    the code is working until line 11. There, I get the following error.
    "Values does not fall within the expected range."

    I don't know why? I have no clue.
    Thank you for your support!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    It sounds like that ENUM value is not available on the version of CF you are using (i.e. they didn't implement it)
    If you check MSDN does it say those values are supposed to be available in the compact framework?

    Comment

    • rinoesc
      New Member
      • Feb 2009
      • 3

      #3
      WebRequestMetho ds is not implemented in .NET Compact Framework but is implemented in OpenNETCF Framework.

      i'm using this in my code.
      WebRequest.Regi sterPrefix("ftp ", new FtpRequestCreat or());
      and WebRequest is not implemented in OpenNETCF Framwork.

      Could this be the problem?


      here is my entire code

      Code:
      using System;
      using System.Linq;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Text;
      using System.Windows.Forms;
      using System.Net;
      using System.IO;
      using OpenNETCF.Net;
      using OpenNETCF.Net.Ftp;
      
      
      
      namespace TestFTP
      {
          public partial class Form1 : Form
          {
              public Form1()
              {
                  InitializeComponent();
              }
      
              private void button1_Click(object sender, EventArgs e)
              {
                  ConnectionManager conexiuni = new ConnectionManager();
                  ConnectionDetailCollection detaliiconexiuni = conexiuni.GetConnectionDetailItems();
                  foreach (ConnectionDetail conexiune in detaliiconexiuni)
                  {
                      if (conexiune.Description == "MyWorkConnection" || conexiune.Description == "myworkconnection")
                      {
                          conexiuni.Connect(conexiune.DestinatonNetwork, false, ConnectionMode.Synchronous);
                          MessageBox.Show("S-a facut conexiunea");
                      }
                  }
      
                  string pathu = "ftp://10.0.1.100/_desc.txt";
                  MessageBox.Show("S-a definit pathu de conectare");
                  Uri serveru = new Uri(pathu);
                  MessageBox.Show("S-a definit Uri");
                  WebRequest.RegisterPrefix("ftp", new FtpRequestCreator());
                  MessageBox.Show("S-a inregistrat prefixu ftp");
                  try
                  {
                      if (serveru.Scheme != Uri.UriSchemeFtp)
                      {
                          throw new ArgumentException("Adresa nu e de tip ftp");
                      }
      
                      FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(serveru);
                      MessageBox.Show("S-a definit requestu");
                      request.Binary = true;
                      MessageBox.Show("S-a definit request Binary");
                      request.Credentials = new NetworkCredential("myuser", "mypass");
                      MessageBox.Show("S-au definit credentialele");
                      request.Method = OpenNETCF.Net.WebRequestMethods.Ftp.DeleteFile;
                      MessageBox.Show("S-a definit metoda");
      
      
                     
                  }
                  catch (Exception exceptia)
                  {
                      throw exceptia;
                  }
              }
      
              private void button2_Click(object sender, EventArgs e)
              {
                  Application.Exit();
              }
          }
      }
      Thank you

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        I am unfamiliar with third party openNETCF, you might try asking them?
        If you are trying to mix a feature available in one with a feature available in another, I think you will run into problems (like this one)

        Comment

        • lantoeter
          New Member
          • Apr 2009
          • 1

          #5
          Hello,

          did you solve the problem i have the same. but in my case the
          downloadRequest .Method = WebRequestMetho ds.Ftp.ListDire ctory;
          doesent work.

          lantoeter

          Comment

          • JJMC
            New Member
            • Jun 2010
            • 1

            #6
            values out of expected range

            Did anyone figure this out, i am trying to ftp file, here is error i am getting
            "Values does not fall within the expected range."

            same as RinoEsc

            Comment

            Working...