By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 720 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

C# Problem with WebRequestMethods

P: 3
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...

Expand|Select|Wrap|Line Numbers
  1. string pathu = "ftp://10.0.1.100/florinpa/_desc.txt";
  2. MessageBox.Show("S-a definit pathu de conectare");
  3. Uri serveru = new Uri(@pathu);
  4. MessageBox.Show("S-a definit Uri");
  5. FtpWebRequest request = FtpWebRequest)FtpWebRequest.CreateDefault(serveru);
  6. MessageBox.Show("S-a definit requestu");
  7. request.Binary = true;
  8. MessageBox.Show("S-a definit request Binary");
  9. request.Credentials = new NetworkCredential("florinpa", "corcodel");
  10. MessageBox.Show("S-au definit credentialele");
  11. request.Method = WebRequestMethods.Ftp.DeleteFile;
  12. MessageBox.Show("S-a definit metoda");
  13.  
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!
Feb 17 '09 #1
Share this Question
Share on Google+
5 Replies


Plater
Expert 5K+
P: 7,872
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?
Feb 17 '09 #2

P: 3
WebRequestMethods is not implemented in .NET Compact Framework but is implemented in OpenNETCF Framework.

i'm using this in my code.
WebRequest.RegisterPrefix("ftp", new FtpRequestCreator());
and WebRequest is not implemented in OpenNETCF Framwork.

Could this be the problem?


here is my entire code

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Net;
  10. using System.IO;
  11. using OpenNETCF.Net;
  12. using OpenNETCF.Net.Ftp;
  13.  
  14.  
  15.  
  16. namespace TestFTP
  17. {
  18.     public partial class Form1 : Form
  19.     {
  20.         public Form1()
  21.         {
  22.             InitializeComponent();
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             ConnectionManager conexiuni = new ConnectionManager();
  28.             ConnectionDetailCollection detaliiconexiuni = conexiuni.GetConnectionDetailItems();
  29.             foreach (ConnectionDetail conexiune in detaliiconexiuni)
  30.             {
  31.                 if (conexiune.Description == "MyWorkConnection" || conexiune.Description == "myworkconnection")
  32.                 {
  33.                     conexiuni.Connect(conexiune.DestinatonNetwork, false, ConnectionMode.Synchronous);
  34.                     MessageBox.Show("S-a facut conexiunea");
  35.                 }
  36.             }
  37.  
  38.             string pathu = "ftp://10.0.1.100/_desc.txt";
  39.             MessageBox.Show("S-a definit pathu de conectare");
  40.             Uri serveru = new Uri(pathu);
  41.             MessageBox.Show("S-a definit Uri");
  42.             WebRequest.RegisterPrefix("ftp", new FtpRequestCreator());
  43.             MessageBox.Show("S-a inregistrat prefixu ftp");
  44.             try
  45.             {
  46.                 if (serveru.Scheme != Uri.UriSchemeFtp)
  47.                 {
  48.                     throw new ArgumentException("Adresa nu e de tip ftp");
  49.                 }
  50.  
  51.                 FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(serveru);
  52.                 MessageBox.Show("S-a definit requestu");
  53.                 request.Binary = true;
  54.                 MessageBox.Show("S-a definit request Binary");
  55.                 request.Credentials = new NetworkCredential("myuser", "mypass");
  56.                 MessageBox.Show("S-au definit credentialele");
  57.                 request.Method = OpenNETCF.Net.WebRequestMethods.Ftp.DeleteFile;
  58.                 MessageBox.Show("S-a definit metoda");
  59.  
  60.  
  61.  
  62.             }
  63.             catch (Exception exceptia)
  64.             {
  65.                 throw exceptia;
  66.             }
  67.         }
  68.  
  69.         private void button2_Click(object sender, EventArgs e)
  70.         {
  71.             Application.Exit();
  72.         }
  73.     }
  74. }
  75.  
Thank you
Feb 17 '09 #3

Plater
Expert 5K+
P: 7,872
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)
Feb 17 '09 #4

P: 1
Hello,

did you solve the problem i have the same. but in my case the
downloadRequest.Method = WebRequestMethods.Ftp.ListDirectory;
doesent work.

lantoeter
Apr 21 '09 #5

P: 1
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
Jun 23 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.