|
So here's the situation: I'm trying to fetch a series of files from a webserver (the request is handled by a php script which redirects to a txt file,if that matters). I use a BackgroundWorker to loop through the number of files to fetch and a HttpWebRequest to get the filename and contents (I think I have to use HttpWebRequest because I need the filename). Then I use the WebRequests GetResponse() method to get the filename from the headers and the content from the Response stream. However, the program hangs at the third call to GetResponse without fail.No exception, no nothing. This code will reproduce the problem: (It is the minimum I have to do to reproduce it, it only retrieves the filename)
for (int i = Start; i <= End; i++)
{
HttpWebRequest HWR = HttpWebRequest.Create("http://www.deckcheck.net/export.php?deck=" + i.ToString() + "&type=txt") as HttpWebRequest;
HWR.Method = "GET";
HWR.KeepAlive = false;
WebResponse Resp = HWR.GetResponse();
Name = Resp.Headers["Content-disposition"].Substring(Resp.Headers["Content-disposition"].IndexOf("filename=") + 9);
System.Windows.Forms.MessageBox.Show(Resp.Headers["Content-disposition"].Substring(Resp.Headers["Content-disposition"].IndexOf("filename=") + 9));
}
It's always the third call since program startup, too.
I havn't done much network coding, so if you need more info, just ask.
|
|
|
|
|
you're not showing any error handling; if there is none in a BackGroundWorker's DoWork handler and an exception occurs, the DoWork handler will finish right away, the RunWorkerCompleted handler will be invoked, and its e.Error parameter will hold the exception. I recommend:
1. you have a look at e.Error.ToString()
2. provide error handling inside DoWork
|
|
|
|
|
True, I don't have any error handling to speak of. However, I know it's not that kind of error because
A) the RunWorkerCompleted event is never raised
B) Stepping through the code or pausing execution when the program hangs, everything just kind of..stops, at the GetResponse() call. I can't step further.
C) I tried adding a catch both inside the DoWork handler and where I start the backgroundworker going and the result is the same.
Thanks for the tips, though, I really should make exception catching a habit.
|
|
|
|
|
Maybe http://www.deckcheck.net/export.php?deck= is the problem?
Also, you may want to start reading the response stream and close it before displaying a message box. Try reading your headers and response.Close() before using a message box. Also, only because I can't stand it, don't name local variables starting with a capital letter. There is a reason C# is case-sensitive.
|
|
|
|
|
Hi All,
I want to convert EURO currency to GBP,USD,CHF,SEK etc. Dosenot any one knows the formula should i use to convert each currency to EURO. I am getting current rate of each currency.
Thanks
Rahul
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
Currency rates are changing all the while - so you will need to communicate with a web service / site that provides updated currency rates.
Once you have the correct rates, updating the currency should be easy.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Hi Abhinav,
I am getting all the current currency rates just need a formula to convert each curr inEURo.
Will try and let u knkow?
Thanks
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
|
Hi,
I am getting the daily rates. I just want to know the formula to convert.
Suppose i got amount 140 in GBP now i want to convert it into EURO so what will be the formula.
Regards
Rahul
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
Hi,
you will need this formula:
x (in Euro) = y (foreign currency) / z (current rate).
For example for the 140 GBP with a rate of 1 € = 1.5 GBP the formula will be
x = 140 / 1.5 = 93.33 (Euro)
If you have the rate like 1 GBP = 0.67 Euro you need this formula:
x (in Euro) = y (foreign currency) * z (current rate)
Hope this helps.
Regards
Sebastian
|
|
|
|
|
the formula is: multiplication.
It is similar as converting inches to millimeters, and much simpler than converting Fahrenheit to Celsius.
|
|
|
|
|
I am writing an application to migrate records from a DocuShare document management system to a TRIM Records management system.
Moving documents (anything that is not an email) is straight forward, but for some reason DocuShare takes any email that is lodged and ripps it up into component pieces and stores these in a database table.
I can find the To, From, Subject, Body, Header and other data and now my challenge is to reconstitute the original email so I can move it into TRIM.
I have tried using the Office.Interop.Outlook class to create an email, but I can't include the Header or the From Information.
I.E.
Outlook.MailItem mailItem = new Microsoft.Office.Interop.Outlook.MailItem();
mailItem.Body = "This is My Test";
mailItem.Subject = "Test Message";
mailItem.Attachments.Add("C:\\AttachmentDocument.txt", Outlook.OlAttachmentType.olByValue, 1, "AttachmentDocument.txt");
mailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
mailItem.To = "ToPerson@theirEmail.Address.com";
mailItem.BCC = "";
mailItem.CC = "";
mailItem.SaveAs("Path", Outlook.OlSaveAsType.olMSG);
Does anyone know of an other way to recreate these emails so that I can include the header and from (and maybe other) fields?
|
|
|
|
|
RCoate wrote: DocuShare
You might want to have a look at their documentation to see if they provide any solutions.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Yeah, DocuShare documentation is fairly sparse, does not cover anything other than documents (nothing on emails) and is really quite useless.
I have done quite a bit of research on all available DocuShare tools, sdk's and api's before starting this project.
One thing I found out from dissecting their database is that they do not save emails (unless the email is an attachment to another email), so you can not export emails.
|
|
|
|
|
How do you take a byte array and get a textbox to display it as it is bit wise.
So for example if I have a byte it gets displayed as maybe 00010100
thanks for helping out the newbie
ps: Please reply if you want to share how to do this and do not reply otherwise... thanks.
|
|
|
|
|
Hi,
This should be the solution: (copied from MSDN)
txtFieldInBinary.Text = Convert.ToString(valueToDisplayAsBinary, 2);
|
|
|
|
|
You could write your own code to do this -
public class ShowBits {
public static void Main() {
int t;
byte val;
val = 123;
for(t=128; t > 0; t = t/2) {
if((val & t) != 0) Console.Write("1 ");
if((val & t) == 0) Console.Write("0 ");
}
}
}
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
public class ShowBits {
public static void Main() {
byte val;
val = 123;
for(int i = 7; i >= 0; i--) {
Console.Write(((val >> i) & 1) + " ");
}
}
}
|
|
|
|
|
Hi Thanks for answering.
I don't understand (val & t).
I will look it up
|
|
|
|
|
Here's[^] an older article of mine that has what you need and more.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
No need for explicit loops. I'd go for
string binary=Convert.ToString(myUnsignedByte, 2).PadLeft(8, '0');
which yields 8 binary digits.
|
|
|
|
|
Ok I found that there's a Convert.ToString for that
http://msdn.microsoft.com/en-us/library/14kwkz77.aspx
|
|
|
|
|
Hi All,
I am using the XYNTServices example I found here. If I start the Service with everything using local computer resources it works great. However, I want to be able to place the log file it creates on a server rather then the local computer. Does anyone out there know how to accomplish this? I have tried mapping the server resource to a drive letter, I have tried using the complete IP address to the resource folder and I have tried using the \\servername\folder\folder\logfile.log None of which have worked! So any information on how this can be made to work would be greatly appreciated. Oh almost forgot if I use the \\IPAddress\folder\folder\logfile.log in this case it does in fact create the log file on the server, but then the windows service won't start. I keep getting the "Could not start the MyWinService service on Local Computer."
"Error 1053: The service did not respond to the start or control request in a timely fashion." Both statements without quotes of course. So the only change is to the path of the log file. Again ANY help would be appreciated!
Thanks,
Charlie
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0 Visual Studio 2005
|
|
|
|
|
Charlie Curtis wrote: XYNTServices example I found here
You might want to provide a link to this article. Or better still, you could post this question at the bottom of the article (in the messages section).
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Thanks for... Nothing
Everything is Free... Until You Have to Pay for it...
Platforms Windows 2000/XP Professional using Visual C++ 6.0 Visual Studio 2005
|
|
|
|