I need data from a *.geo file. I want read it with StreamReader. The data are on the local maschine but the Internet Explorer or what ever can´t read the data. What can i do to solve this problem?
StreamReader myFile = new StreamReader(filename); while ((Content = myFile.ReadLine()) != null) { foreach (string ss in Content.Split(sep)) { mylist.Add(Convert.ToDouble(ss, en)); } }
if i try to use System.Windows.Forms it give me a error [*-)]
this is the complete class to access the data
public class Geo_Daten {
public List<double> ReadFile(string filename) { CultureInfo en = new CultureInfo("en-US"); string Content = ""; List<double> mylist = new List<double>(); if (filename.Length > 0) { char[] sep = new char[] { ' ' }; StreamReader myFile = new StreamReader(filename); while ((Content = myFile.ReadLine()) != null) { foreach (string ss in Content.Split(sep)) { mylist.Add(Convert.ToDouble(ss, en)); } } } remove_from_list(mylist); return mylist; }
Geo_Daten daten = new Geo_Daten(); List<double> mylist = new List<double>(); mylist = daten.ReadFile(@"C:\Dokumente und Einstellungen\Joe\Desktop\tmp_geo\masi3cosock1.geo");
_Joe_
Member
1 Points
14 Posts
Streamreader
Jan 05, 2009 01:48 PM | LINK
Hi
I need data from a *.geo file. I want read it with StreamReader. The data are on the local maschine but the Internet Explorer or what ever can´t read the data. What can i do to solve this problem?
Lars Buchlei...
Participant
1667 Points
336 Posts
Re: Streamreader
Jan 05, 2009 01:53 PM | LINK
what do you mean by "cant link" ? can´t open? can´t find?
_Joe_
Member
1 Points
14 Posts
Re: Streamreader
Jan 05, 2009 01:58 PM | LINK
can´t open
in a normal *.cs Projet it works but in a Silverlight project [:(]
Lars Buchlei...
Participant
1667 Points
336 Posts
Re: Re: Streamreader
Jan 05, 2009 02:04 PM | LINK
You treid it in this way
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "GEO Files (.geo)|*.geo";
ofd.FilterIndex = 1;
if (ofd.ShowDialog()==true)
{
FileStream f = ofd.File.OpenRead();
StreamReader sr = new StreamReader(f);
MessageBox.Show(sr.ReadToEnd());
sr.Close();
f.Close();
}
if yes whats the error you get?
_Joe_
Member
1 Points
14 Posts
Re: Re: Streamreader
Jan 05, 2009 02:17 PM | LINK
i don´t want to open a dialogbox. hmm...
*edit*
if i try to use System.Windows.Forms it give me a error [*-)]
this is the complete class to access the data
Lars Buchlei...
Participant
1667 Points
336 Posts
Re: Re: Re: Streamreader
Jan 05, 2009 02:57 PM | LINK
but thats the point ! You can´t just access the local harddrive from a Sl App for security Reasons.
2 ways to achive this, use isolated storage or prompt the user to open the file.
_Joe_
Member
1 Points
14 Posts
Re: Re: Re: Streamreader
Jan 05, 2009 03:10 PM | LINK
thx, it make sense
the namespace System.Windows.Forms doesn't not exist .
How can i get the Windows Forms? For the Prompt
Lars Buchlei...
Participant
1667 Points
336 Posts
Re: Re: Re: Re: Streamreader
Jan 05, 2009 03:25 PM | LINK
it doesnt exist, just use the open file dialog, of my previous post.
I doubt that it can be styled, it´s tho os OFD
_Joe_
Member
1 Points
14 Posts
Re: Re: Re: Re: Streamreader
Jan 07, 2009 07:52 AM | LINK
I have put all my data on a ftp Server. How can i get them?
i try it with a HttpWebRequest but it doesn't work
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.xy.de/abc.geo");
all is red underlined ?
Lars Buchlei...
Participant
1667 Points
336 Posts
Re: Re: Re: Re: Re: Streamreader
Jan 07, 2009 08:23 AM | LINK
afaik a thing like the ftpwebrequest of the big netframework is not implemented right now in the sl library( but i expect such in SL3 in March)
So 2 workaround ideas
1. use a ftp server with a http interface and use this
2.let your webapp fetch the file and transfer it through webservice