|
devvvy wrote: 3. any chance there's a way to instantiate generic at runtime? (QUESTION 2)
Last I checked, no there isn't. Generic types are determined and code written by the compiler at compile time. This is because Generics are "syntactic sugar", basically, writing overloaded code for you to handle each type (T) that the compiler finds instances of.
|
|
|
|
|
|
Dear all,
perhaps someone can help me. I'm trying to write a program that retireves information from my amazon seller account, but it fails to get the cookies Amazon sends me.
I have the following code:
CookieContainer cookies = new CookieContainer();
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://www.amazon.de/gp/sign-in.html?ie=UTF8&email=...@web.de");
req.CookieContainer = cookies;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
The cookies do not end up in the cookie container of the response, even though I can see them in the response header. Cookies from another website work.
I have now discovered that the program perhaps cannot handle the format of the set-cookie header correctly when parsing the cookies.
The cookies that don't work have the expiration date given as
Expires=Fri Dec 05 12:05:33 2008 GMT
while cookies from another host that can be parsed have it as
Expires=Fri, 05-Dec-08 12:05:33 GMT
Could this really be the cause for the cookie to be rejected by automatic parsing? If so, how can I set the format string for the application so it will parse the cookies correctly?
Any help is greatly appreciated
Reiner
|
|
|
|
|
I have the same problem (in amazon as well
I use the following regexp:
string regexp = "(?<name>[^=]+)=(?<val>[^;]+)[^,]+,?";);
MatchCollection myMatchCollection = Regex.Matches(cookiesStr, regexp);
foreach (Match myMatch in myMatchCollection)
{
string cookieName = myMatch.Groups["name"].ToString();
string cookieVal = myMatch.Groups["val"].ToString();
Cookie cookie = new Cookie(cookieName, cookieVal);
cookies.Add(cookie);
}
Note that I only care about the cookie name/value...
good luck
Elia
|
|
|
|
|
I am trying to create an application where, if new drive has been detected by the windows operating system, an event on the application is triggered.
Although what i was planning to do is the application to check for new drives in a given time interval but seems like that is not the appropriate thing to do.
Any suggestions?
|
|
|
|
|
hello
use the concept of threads
thks
|
|
|
|
|
I'm actually using thread to keep on scanning on every time interval but don't you think that's not a good idea?
|
|
|
|
|
Hi,
for a Control (a Form is a Control) you can override WndProc and check for
wParam==WM_DEVICECHANGE
That will give you an event whenever a device (such as a camera, USB memory stick, ...)
gets added or removed.
|
|
|
|
|
Try responding to the WM_DEVICECHANGE[^] window message. A WParam value of DBT_DEVICEARRIVAL[^] should indicate a new cd/usb drive.
Will probably only work if you have auto insert notification turned on for the drive.
[Edit: Oops, should have hit refresh before posting. I agree with Luc]
Simon
|
|
|
|
|
Hello,
I get the error "No conenction could be made because the target machine actively refused it 192.168.1.2:1234"
It works very fine in localhost but when i tried to connect to other pc on web it gives me above error.
So will you please help me?
Thank you.
|
|
|
|
|
Are you running the server on that PC? Did you make sure the firewall is not blocking?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hello,
I dont know how to make the firewall settings for that port.
|
|
|
|
|
krinaljariwala wrote: I dont know how to make the firewall settings for that port.
That is outside the scope of a C# question. Ask your network admin.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I want to load data that have already saved in a file to a listbox. My code here doesn't work, there's nothing happen in the listbox eventhough there are some items in the file that should be loaded to the listbox. Where is my mistake?
//the code below to load, but nothing happen
private const string Filename = "DDBlock.txt";
public void Main(String[] args)
{
this.listBoxBlockedNumberDD.Items.Clear();
if (File.Exists(Filename) == true)
{
using (StreamReader sr = File.OpenText(Convert.ToString(Filename)))
{
foreach (string Item in Filename)
{
listBoxBlockedNumberDD.Items.Add(sr.ReadLine());
}
}
}
}
//the code below to save item in listbox to a file, it works and the item is saved to the file.
private void menuItemDD_Click(object sender, EventArgs e)
{
listBoxBlockedNumberDD.Items.Add(RemoveText(textBoxPhoneNumber1.Text.Trim()));
using (System.IO.StreamWriter sw = new System.IO.StreamWriter(Filename, true))
{
foreach (string Item in this.listBoxBlockedNumberDD.Items)
{
sw.WriteLine(Item);
}
sw.Close();
}
textBoxPhoneNumber1.Text = string.Empty;
}
|
|
|
|
|
irsalina wrote: foreach (string Item in Filename)
What do you expect this to do ? It's going to iterate once, perhaps. There is one string in filename, it's a string.
Try File.ReadAllLines instead, then use a foreach on the result, passing each string directly in, without having to use a streamreader at all.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Well, i've came out with this:
if (File.Exists(Filename) == true)
{
//Open the file and read all lines
string readDD = File.ReadAllLines(Filename);
{
foreach (string dd in readDD)
{
listBoxBlockedNumberDD.Items.Add(dd);
}
}
}
But there is an error that said "System.IO.File does not contain a definition for ReadAllLines". From what I know, System.IO has already been implemented in System.dll and mscorlib.dll and I've had those. I also have installed v1.1.4322 .Net and it should've worked. So, where do u think my fault?
Thank you so much
ichiwa
[student]
|
|
|
|
|
It's for delete data from listbox and txt file in windows mobile. I've came up until this.
private void menuItemUn_Click(object sender, EventArgs e)
{
//delete item in list box
if (listBoxBlockedNumberDD.SelectedIndex == -1)
{
MessageBox.Show("Nothing selected.", "Alert!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
return;
}
listBoxBlockedNumberDD.Items.Remove(listBoxBlockedNumberDD.SelectedItem);
//delete the item in file? what should I put in here
}
ichiwa
|
|
|
|
|
Your best bet is to overwrite the file with that line removed. You can't just remove a line from a file, it doesn't work that way. You save the file with the line gone.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hi.. i need multiple columns in Autocomplete Textbox which is reside inside the grid...
|
|
|
|
|
Reword your question because I have no idea what you mean. If you need help, take some time in wording your question properly--at least.
|
|
|
|
|
Do you mean to develop textboxes at header of grid for filtering or something like that.
I didn't understand the question clearly but try using templatecolumn
|
|
|
|
|
You might want to look for editable combobox with multi columns instead.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hello all,
In VisualStudio 6.0, there's an Export Makefile menu item
that creates a makefile for the project. Is there any way to achieve this in VS.Net 2005? Basically, I need a command-line build script for my project and was wondering if there's
an automated way to generate it for an existing VS.Net project.
Thks
T J S
|
|
|
|
|
No, and ask this in the VS forum.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I've come across some classes in the .NET framework that have no constructors defined, but are not static classes. For example, to instantiate an AppDomain class, you call the static function AppDomain.CreateDomain() which returns an instance of the AppDomain class. There are no constructors defined for the class, so you cannot instantiate the class using the new keyword.
My question is how does the CreateDomain() function instantiate the class?
Thanks in advance,
Kevin
|
|
|
|