|
Hi,
I ran the code below, which is basically yours (I now count the lines, and I fixed your Console output which was reading another line):
log("start");
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create("ftp://ftp.microsoft.com");
req.Proxy = null;
req.Method = WebRequestMethods.Ftp.ListDirectory;
using (FtpWebResponse res = (FtpWebResponse)req.GetResponse()) {
StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
int count=0;
for( ; ; ) {
string fileName = sr.ReadLine();
if (fileName==null) break;
log(fileName);
count++;
}
log("Received "+count+" lines");
}
and got what I was expecting:
23:46:20.277 CPTest.log-42 start
23:46:25.932 CPTest.log-42 bussys
23:46:25.945 CPTest.log-42 deskapps
23:46:25.958 CPTest.log-42 developr
23:46:25.970 CPTest.log-42 KBHelp
23:46:25.983 CPTest.log-42 MISC
23:46:25.996 CPTest.log-42 MISC1
23:46:26.009 CPTest.log-42 peropsys
23:46:26.037 CPTest.log-42 Products
23:46:26.050 CPTest.log-42 PSS
23:46:26.063 CPTest.log-42 ResKit
23:46:26.077 CPTest.log-42 Services
23:46:26.086 CPTest.log-42 Softlib
23:46:26.281 CPTest.log-42 Received 12 lines
So that tells me the Microsoft server and your client code are rather compatible, so there might be
something wrong with your Internet connection, although I can't begin to understand what it might be.
Is it special in any way? maybe extremely slow? I suggest you try with a well established FTP client so you can feel how it reacts, and maybe see some errors/warnings.
FYI: I did try Microsoft's site with FileZilla 3.1.2, and my Internet is a 3Mb/s ADSL.
|
|
|
|
|
Luc, for you, I keel dee bool!
It was that extra read that swung it.
|
|
|
|
|
Brady Kelly wrote: I keel dee bool
I don't know that bull, but you're welcome.
|
|
|
|
|
Come to think of it, since you where reading two lines per iteration, you only showed six,
and you might (did) try and read a line after you tested for null. That must be why the stream objected.
BTW: the code you showed originally was incorrect in a different way, and would not have compiled.
I guess you are better of showing actual code right from the start.
|
|
|
|
|
Yes, I just didn't have the original code at hand. BTW, why wouldn't it compile? The only reason I can see is that it's incomplete, but I just posted an excerpt.
This one was a nasty. The original code was getting an FTP 550 error, file not found or no access, because the directory I was trying to create already existed. It made no check of this, and almost ignored the FTP error by only catching and logging the exception. Because I was breaking when thrown, I noticed an exception that is actually often expected, but I suspected my changes, adding authorization, had introduced the problem. Because another developer had broken the function I needed to execute the code, I extracted it into a separate project to experiment, beginning my troubles.
[Edit]
Ah, I see in the original code that I was trying to write the StreamReader, not the filename, which results in System.IO.StreamReader appearing in the console, just before the same disposed object exception.
[/Edit]
|
|
|
|
|
Brady Kelly wrote: Ah, I see ...
right.
Brady Kelly wrote: I just didn't have the original code at hand
Which is a pity. The original post didn't show a double ReadLine (the extra one without null-test);
if it had, I guess some one would have noticed earlier.
Anyway, the detour with the Microsoft server allowed me to run your code and compare results.
Glad I could be of help.
|
|
|
|
|
|
You're welcome.
|
|
|
|
|
Luc Pattyn wrote: I use ListBoxes for line-oriented text (not TextBoxes)
Just curious. How do you handle editing? Superimpose a TextBox on the edited line?
|
|
|
|
|
I changed my sig to the textbox/picturebox stuff since too many people get into trouble,
they either start drawing on top of a picturebox and complain an image.save doesn't capture the drawing,
or they have trace/log output in a (rich)textbox and they don't get it to work properly and/or it starts to slow down dramatically as the number of lines increases.
Most of my listboxes are for output only; I have done some editing though, just handling all the key/mouse stuff myself. I don't like (rich)textboxes, they don't scale well. I basically did my own editor based on a Panel; I can teach it every trick I want without constantly fighting RTF troubles.
Brady Kelly wrote: Superimpose a TextBox on the edited line?
Have done that too (single-line textbox on top of label), it works rather well. Solves some of the read-only problems.
|
|
|
|
|
I am kind of asking a general question here. When you use the focus function in winforms, it takes the cursor away. What I mean is id I have a control called uxTxtbox and another one called uxBtnSubmit and I go with uxBtnSubmit.focus();, it will then remover my cursor from the textbox and highlight the button but the user needs to type something in. That is I could call the text changed event of the text box but that of course would mean each time the user typed something in, he would have to click the text box again to add another character. Now I know I could easily just call a keypress event of enter and do a uxBtnSubmit.PerformClick() but I kind of think that would just be avoiding the whole thing. Plus, a smart user will see that the submit button isn't highlighted and will think that they have to click the button or tab over to it. Is there a way that the button can be highlighted the while user is typing?
|
|
|
|
|
The button being highlighted means that it has focus. The textbox being highlighted means that the textbox has focus.
If the button is 'highlighted' (if it has the focus) then the cursor is standing on that button. (You can't see it, but if you press the spacebar, you'll interact with the control that has focus - the button).
Only one control can have the input-focus at a time.
I are troll
|
|
|
|
|
I knew there was a solution. You are not supposed to mess around with the focus for the submit button. If you set the acceptbutton property of the form to the button you want, then it will always be highlighted and when you press enter it will be pressed.
|
|
|
|
|
Hi there! I need some help with events for dynamicly created objects. The code below illustrates the problem. My situation will be a little different since the objects I will be dynamicly creating will be custom, but the problem is the same.
The event will only fire on the last created object. How can I have an event fired within the form Class each time an individual instance of the label is clicked??
Public Class Form1
Friend WithEvents lbl As Label
Private i As Integer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
i = 1
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
lbl = New Label
lbl.Name = "lbl" & i
lbl.Text = "Label " & i
lbl.Location = e.Location
lbl.AutoSize = True
Me.Controls.Add(lbl)
i += 1
End Sub
Private Sub lbl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbl.Click
MsgBox(lbl.Text)
End Sub
End Class
|
|
|
|
|
you must read about delegates in .net....
Anshuman Singh
|
|
|
|
|
This code won't work. You only have one label wired up with it. Basically, you can't use WithEvents on a class-level variable and expect this to work. Drop the "Friend WithEvents..." line completely. Your MouseUp code has to create the label and wire up the events itself. This way, every label you create will maintain event connections.
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
Dim lbl As New Label
' lbl.Name = "lbl" & i ' Drop this line. It's not necessary
lbl.Text = "Label " & i
lbl.Location = e.Location
lbl.AutoSize = True
AddHandler lbl.Click, AddressOf lbl_Click
Me.Controls.Add(lbl)
i += 1
End Sub
and drop the "Handles lbl.Click" from the end of the Sub you defined.
|
|
|
|
|
Works great! thanks for your help.
|
|
|
|
|
Hi,
my application wit database accsess is running fine on the System I developed it. When distibuting it on a other PC - without installation - I get the error message "Can't find System.EnterpriseServices.Wrapper.dll or one of it's dependencies". In former times this method worked fine but no I have a new target system. Is there a workaround for that.
Michael
|
|
|
|
|
How to get the datagrid header value? I have VS 2003 and not able to use Datagridview so is there any other work around?
|
|
|
|
|
what you want to do exactly please explain.....
Anshuman Singh
|
|
|
|
|
Singh,
Thank you for your interest on this post but I got it all figured out.
First I connect to the database then query the table and set it as DataTable. From the datatable I managed to looped for inconsistent Header and display them onto Comboboxes as Lists
adapter.Fill(dt)
Dim dc As DataColumn
For Each dc In dt.Columns()
....
end
|
|
|
|
|
Whenever i am trying to access C# ActiveX control on web page getting following exception.
Application attempted to perform an operation not allowed by the security policy.
To grant this application the required permission,
contact your System administator , or use the Microsoft .NET Framework Configuration tool.
Request for the permission of type ,
'System.Security.Permissions.UIPermission, mscorlib,
version=2.0.0.0, Culture=neutral,
PublicToken=b77a5c561934e089' failed.
Thanks in advance !!!
Dattatraya
modified on Wednesday, January 14, 2009 8:52 AM
|
|
|
|
|
contact your System administator , or use the Microsoft .NET Framework Configuration tool.
I are troll
|
|
|
|
|
Hello,
I have installed VS.net 2005 and i want to know the additional softwares required for developing mobile applications using VB.net 2005.
When i try to create any sample application, it shows message to install .NET Framework 1.0.
but When i try to install .NET Framework 1.0 it says that Framework 1.1 should be installed first.
Please anyone can list the softwares required, also please can give me some idea or sample code to start developing for my Nokia 3230.
Thanks In Advance.
|
|
|
|
|
Hello Friends,
I have a requirement of getting the selected value from crystal report view to my .net application and using that value set datasource to other report.
Kindly help me how can I get the selected value from crystal report view to my application.
Thanks in advance
Regards
|
|
|
|