|
Hi guys,
I'm developing a C# Windows application which makes a HTTP POST for uploading a file from the local system to the remote web server. I need to show the progress of uploading (ie. No of bytes uploaded and time remaining) in a progress bar of the Windows application. Can you guys please help me how to get the progress information of the HTTP POST.
Thanks in advance.
Param
|
|
|
|
|
Usually this is achieved by sending a predetermined number of bytes at a time in chunks and reported back to the user how many of the bytes have been sent and how long it has taken the whole operation to execute.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
So, do you mean to say that I must send segments of predefined number of bytes and I've to reassemble the segments at the remote server? Any other alternatives? Does the .NET HTTP Request class contain any parameter to report the number of bytes sent or is there any event triggered to report the same?
Param
|
|
|
|
|
I have not seen anything that tells you how many bytes have been sent. The solution I have mentioned is the only one I know of. Maybe someone else will come along with other ideas.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi all,
I am currently involved in a school assignment in which I have to use DrScheme together with C#. I know how to invoke a Scheme function from C# via calls through the MysterX library. The library also allows events to invoke on COM classes and components, but the only example I can find are Microsoft-defined COM classes, like ADOConnection.
Is it possible for DrScheme, via MysterX, to invoke a C# program's methods? (Is a C# program considered a COM class?) I have hunted high and low everywhere but couldn't find an example at all.
Note: It's not a requirement of the assignment to do this; it's just that our group, for some added functionality, wants to use Scheme for scripting, much like Scheme for GIMP, but the documentation is really sparse and there are no examples. If I can just get one example of calling a method in a C# program from Scheme with MysterX then I believe I can figure out the rest myself
Thanks in advance!
|
|
|
|
|
Not sure, I've never worked with DrScheme. Have you asked your teacher?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I'm using Visual Studio 2005 and have a Form with a MaskedTextBox.
In the Property Grid, i set AsciiOnly to true. All other properties
are unchanged. Despite that, when I run the program, the MaskedTextBox
still accepts numerals and commas, etc... To my knoledge when the AsciiOnly
is set to true, the MaskedTextBox is supposed to restrict input to only A-Z and a-z.
It appears that the AsciiOnly property is not working.
Am I missing something here?
------------------------------------------------
"We are disturbed not by events, but by the views which we take of them.
I must die. Must I then die lamenting? I must be put in chains. Must I then also lament? I must go into exile. Does any man then hinder me from going with smiles and cheerfulness and contentment?"
- Epictetus (Greek Stoic Philosopher)
|
|
|
|
|
Paul Chin PC wrote: "We are disturbed not by events, but by the views which we take of them."
MSDN says: MaskedTextBox.AsciiOnly gets or sets a value indicating whether the
MaskedTextBox control accepts characters outside of the ASCII character set.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yes, I already know that.
MSDN also says:
"If true, AsciiOnly restricts user input to the characters a-z and A-Z. ASCII control characters are not allowed. "
But it doesn't work. When I set the Property to AsciiOnly, the MaskedTextBox still
accepts characters other than a-z and A-Z. For example, it accepts comma (,), period (.),
numerals (1-9) etc...
Try it and see!
Is this a bug in .NET 2.0?
------------------------------------------------
"We are disturbed not by events, but by the views which we take of them.
I must die. Must I then die lamenting? I must be put in chains. Must I then also lament? I must go into exile. Does any man then hinder me from going with smiles and cheerfulness and contentment?"
- Epictetus (Greek Stoic Philosopher)
|
|
|
|
|
The MSDN statement "If true, AsciiOnly restricts user input to the characters a-z and A-Z.
ASCII control characters are not allowed" is wrong. If it were true, the property should
have been called AsciiLettersOnly.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yes, apparently that is so.
What is the use of having the AsciiOnly property?
It appears to be redundant and non-functional.
Could you provide a scenario or example of how to use this property?
------------------------------------------------
"We are disturbed not by events, but by the views which we take of them.
I must die. Must I then die lamenting? I must be put in chains. Must I then also lament? I must go into exile. Does any man then hinder me from going with smiles and cheerfulness and contentment?"
- Epictetus (Greek Stoic Philosopher)
|
|
|
|
|
Although .NET characters and strings are Unicode, you might want the user to input a string
that does not contain non-ASCII characters, because what will consume them only understands
ASCII (some legacy system, some native code, a given file format, whatever).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I understand. Thanks
------------------------------------------------
"We are disturbed not by events, but by the views which we take of them.
I must die. Must I then die lamenting? I must be put in chains. Must I then also lament? I must go into exile. Does any man then hinder me from going with smiles and cheerfulness and contentment?"
- Epictetus (Greek Stoic Philosopher)
|
|
|
|
|
I use c#.net languae
I want to get the system time of computer shut down.
please give me some example code.than you for help me
|
|
|
|
|
DateTime.Now will give you the system time. Unless you're using an OS that stores the times it was shut down ( such as Windows Server 2003 ), you can't hope to retrieve that info.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Given:
ArrayList aButtons = new ArrayList();<br />
...<br />
<br />
myBtn = System.Windows.Forms.GetButton();<br />
aButons.Add(myBtn);<br />
Later, I can't seem to do this:
aButtons[1].Enabled = true;
Instead, I seem to have to do this:
Button newButton = (Button) aButtons[1];<br />
<br />
newButton.Enabled = true;
Is there any way to access the object directly in the ListArray?
|
|
|
|
|
((Button)aButtons[1]).Enabled = true;
|
|
|
|
|
Wow, that's totally... intuitive. Anybody know why Visual Studio / C# can't parse it the first way?
On the other hand - thanks! I never would have figured that out.
|
|
|
|
|
JoeRip wrote: Anybody know why Visual Studio / C# can't parse it the first way?
Because nothing in this statement indicates aButtons is a collection of Button s:
ArrayList aButtons = new ArrayList();
However, if you used generic collections, you could do:
List<Button> aButtons = new List<Button>();
...
aButtons[0].Enabled = true;
/ravi
|
|
|
|
|
JoeRip wrote: I never would have figured that out
"And that is why you failed in the cave." -- Yoda
|
|
|
|
|
I have updated my RichTextBox but i can't get it to redraw.
I have tried several ways but the only one that somewhat works is to SELECT the data that is being updated .. but that has the nauseating effect on the User of causing the entire RTB text to scroll ... bad bad bad.
(no human input is involved in updating the RTB ... 183 lines are updated in microseconds ... unless SELECT is used ... then it takes a second or so)
The RTB gets updated just great, but i can not get it to redraw.
Suggestions, please.
private void UpdateRemainingTimes()
{
for (int n = 0; n < numReminders; n++)
{
string remainingTimeStr = GetRemainingTimeString(remDate[n]);
int lineIndex = ReminderRTB.GetFirstCharIndexFromLine(n);
int indexToDDD = lineIndex + 16;
ReminderRTB.Text.Remove(indexToDDD,remainingTimeStr.Length); // delete old stuff
ReminderRTB.Text.Insert(indexToDDD, remainingTimeStr); // put in new stuff
}
ReminderRTB.Invalidate(); // ??? does not cause the control to be redrawn ???
}
|
|
|
|
|
Have you tried Refresh and Update methods ??, the Update method should do it.
|
|
|
|
|
yes, i tried:
ReminderRTB.Invalidate();
ReminderRTB.Refresh();
ReminderRTB.Update();
in many flavors and combinations ... lol
i am beginning to wonder if there might be some property i have inadvertantly set that would prevent the redraws.
|
|
|
|
|
I don't recall where I found this but it should solve both of you problems:
Private Const WM_SETREDRAW As Integer = &HB
Private Const WM_USER As Integer = &H400
Private Const EM_GETEVENTMASK As Integer = (WM_USER + 59)
Private Const EM_SETEVENTMASK As Integer = (WM_USER + 69)
Private Declare Auto Function SendMessage Lib "user32.dll" ( _
ByVal hWnd As IntPtr, _
ByVal msg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As IntPtr) As IntPtr
' We want to suspend redrawing because we need to select each
' character in turn to determine its fonts. However, RichTextBox
' appears to be missing some properties to do this, so use API:
' Stops RichText redrawing:
richTextBox1.SuspendLayout()
SendMessage(richTextBox1.Handle, WM_SETREDRAW, 0, IntPtr.Zero)
' Stops RichText sending any events:
Dim eventMask As IntPtr = SendMessage( _
richTextBox1.Handle, EM_GETEVENTMASK, 0, IntPtr.Zero)
' Get the selection extent:
Dim selStart = richTextBox1.SelectionStart
Dim selEnd = richTextBox1.SelectionStart + richTextBox1.SelectionLength
... perform processing here ...
' Turn events back on again:
SendMessage(richTextBox1.Handle, EM_SETEVENTMASK, 0, eventMask)
' Select the correct range (we must do this with events on otherwise
' the scroll state is inconsistent):
richTextBox1.Select(selStart, selSize)
' Turn redraw back on again:
SendMessage(richTextBox1.Handle, WM_SETREDRAW, 1, IntPtr.Zero)
richTextBox1.ResumeLayout()
' Show changes
richTextBox1.Invalidate()
|
|
|
|
|
i am SOOOOOOO embarassed ... complete noobie mistake .. failed to assign the RTB:
adding "ReminderRTB.Text = " to the front of these statements resolved the problem. <<blush>>
ReminderRTB.Text.Remove(indexToDDD,remainingTimeStr.Length); // delete old stuff
ReminderRTB.Text.Insert(indexToDDD, remainingTimeStr); // put in new stuff
... but thanks for trying to help!
|
|
|
|