|
Your right....opened it with a hex editor and found HTML. Renamed the extension to .html and it's the logon page.
Okay so even though I have logged on outside of my app and checked the box to remember me, it does not use that cookie. So how do I pass the username and password in my app to grab the file?
Thanks
Tom Wright
tawright915@gmail.com
|
|
|
|
|
To access files from a website that saves the login in a cookie is hard.
You have to find the cookie the website saved on your computer and send it with the HTTP-Request Header.
(I don't know an other way except the website has a possibility to login per querystring (ex. data.aspx?user=abc&pwd=pwd)).
|
|
|
|
|
If I dumped the html in to a bowser object on my app where the end user logged on, would those credentials carry over to my app? Hope this makes sense.
Tom Wright
tawright915@gmail.com
|
|
|
|
|
I think those credentials will only work in the scope of your app browser object.
But you can download those pdfs if you get your browser object to do this for you.
(I have build an app like yours a time ago and had the same problem, but I managed my browser object
to do the steps (but not downloading) I wanted to automate.)
|
|
|
|
|
Hello gurus and mavens!
I haven't had to post any problems here in a while - which I take to be good sign for me. And this one isn't so much a "problem" as a "question".
I thought the compiler would choke on the following code:
namespace ConsoleApplication1
{
public class MyClass<G>
{
private G Val;
public MyClass(string initStr)
{
if (initStr == "bad init string")
throw new ApplicationException("You can't do that!");
Val = default(G);
}
public MyClass(G initVal)
{
Val = initVal;
}
}
class Program
{
static void Main(string[] args)
{
MyClass<int> example1 = new MyClass<int>("test");
MyClass<int> example2 = new MyClass<int>(1);
MyClass<string> example3 = new MyClass<string>("what happens here?");
}
}
} and tell me that it did not know which constructor to use with example3 since both constructors for MyClass would accept a string. But it didn't! Instead it just elects to use the constructor with the parameter of type string. Not what I expected, and not what I wanted.
To get around this, I changed the second constructor to
public MyClass(G initVal, bool dummy) and the call to
MyClass<string> example3 = new MyClass<string>("what happens here?", true); just to make it clear that I want to use the second constructor.
My question is this: is there a better way to handle this that I am not aware of? Is there some hidden option or obscure construct that makes sense of ambiguous constructor signatures?
Many thanks,
Clive Pottinger
Victoria, BC
|
|
|
|
|
This is expected behavior. MyClass(G) when G is a string becomes MyClass(string) . As a constructor with those parameter types already exists a new one is not generated by the compiler as the parameter list must be different to successfully overload.
|
|
|
|
|
I'd go further and say this is the desired behaviour for the generic overload (i.e. I think the .Net framework makes the correct choice). MyClass(string foo) is explicitly stating "I deal with strings" and is therefore concrete, whereas MyClass(G foo) is stating "I deal with 'G's" which is less concrete.
The design in the OP needs refactoring IMO, the concrete MyClass(string foo) ctor needs to be removed unless there is a specific reason for dealing with strings specifically. The validation performed on the strings is likely to be, but not necessarily, valid for other types.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Thanks guys.
That explains why it acts like it does.
keefb wrote: The design in the OP needs refactoring [...] unless there is a specific reason for dealing with strings specifically.
In the actual code MyClass is a class that represents some kind of value. The first ctor (MyClass(string initStr) ) is used when the initStr holds a formula that needs to be parsed and evaluated to get the value. The second ctor (MyClass(G initVal, bool dummy) ) is used when the value is already known, and does not need to be parsed or evaluated. The confusion arose, of course, when the value is a known string.
I will take your recommendation to remove the first ctor into consideration, but at this point, I don't see a way for it work (is MyClass("foo()") a request for the string returned by foo or for the string "foo()"?). In the meantime, I will take it that my "workaround" is not wrong/dangerous/problematic/laughable.
Thanks again.
Clive Pottinger
Victoria, BC
|
|
|
|
|
Clive D. Pottinger wrote: The first ctor (MyClass(string initStr)) is used when the initStr holds a formula that needs to be parsed and evaluated to get the value
This is a worry*, and the source of your problem. If possible, you should defer the instantiation of this class until you have the value you want to use. If I understand you correctly, by passing the formula as a string will require the current class to be responsible for performing the parsing as well as whatever this class is meant to do with the result, this is probably bad object encapsulation.
A better way to handle this is to create an object which is responsible for the storage and parsing of the formula, and pass the results of the formula into the current class ,explained in your original post. This will separate the concerns more clearly.
* This is a worry because, unless you are parsing text entries from a user or some other source (e.g. text input from a UI or file), writing formulas in strings and then evaluating them is bad design (and a real pain. If this is the case, then it's unavoidable. If you are just using this to pass formulae around within the application, you should look at c# delegates(which allow you to pass methods around as parameters) and possibly the strategy pattern.
Hope this helps!
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Thanks for the clarification, keefb.
keefb wrote: If I understand you correctly, by passing the formula as a string will require the current class to be responsible for performing the parsing as well as whatever this class is meant to do with the result, this is probably bad object encapsulation.
Agreed. But the class is not actually responsible for the parsing or evaluation (it passes those tasks off to another class), nor is it responsible for acting on the value. The class just holds on to expression tree created by parsing the formula and uses it to provide a value when requested. Perhaps my original example was over-simplified.
keefb wrote: ...unless you are parsing text entries from a user or some other source (e.g. text input from a UI or file), writing formulas in strings and then evaluating them is bad design...
This is exactly what I am doing. The formulas are read from user-created XML files and used to control the program's behaviour. This is fun... every criticism you offer just seems to confirm that I'm doing it correctly . Keep going, keefb... one more critique should cement that I'm the bona fide genuis that I always knew myself to be (no matter what those jerks at Mensa had to say )
Clive Pottinger
Victoria, BC
|
|
|
|
|
hi all,
I have a client-server project and i want to connect to the server from the client by socket via proxy..
any one can help me ??
thanks all
|
|
|
|
|
I have a third party dll that is written in C++ that saves a bitmap image as the actual grayscale values and not a Bitmap format. I am looking for a way to read in the grayscale values and convert them to use C#/.NET 's Bitmap class.
Thanks
|
|
|
|
|
|
Hi everyone.
I am currently playing around with XML files and gridview, and wondered if there were any easy way to filter data, so only rows with specific content are shown.
I have the following.
DataTable dt = new DataTable("Subscribers");
dt.Columns.Add("ID");
dt.Columns.Add("Email");
dt.Columns.Add("signup");
dt.Columns.Add("recent");
dt.Columns.Add("Amount");
dt.Columns.Add("Status");
dt.ReadXml(Application.StartupPath + @"\subscribers.xml");
dataGridView1.DataSource = dt;
dataGridView1.Refresh();
and would like to filter it so rows who fx. only have the value 0 in the columns "Status" would be shown.
Initially hoped that I could use dt.Select("Status == 0") but that didnt work.
so any supercoders out there? yes, yes i did try to google my issue, but didnt find any solution to my small challenge here...
other alternative that I will go back to my good old SQL Server, skip XML files and just use what I am used to - but that would be too easy...
|
|
|
|
|
Try it with dt.Select("Status = 0")
|
|
|
|
|
no, that didnt work either. (too bad though)
|
|
|
|
|
See this example (it works):
DataTable dataTable = new DataTable("MyTable");
dataTable.Columns.Add("Column1");
DataRow dataRow = dataTable.NewRow();
dataRow["Column1"] = "0";
dataTable.Rows.Add(dataRow);
DataRow[] foundRows = dataTable.Select("Column1 = 0");
Trace.Write(foundRows);
Have you checked your dataTable ?
Are there rows with content 0 in Status ?
|
|
|
|
|
Yes, well came to the conclusion that the error for me is that I thought it would be enough to add a line into the code and that would be that. But can see that I need to do more than that.
Basically tried to add
dt.Select("Status =1"); after reading the XML file and also tried to filter it like this
dataGridView1.DataSource = dtSelect("Status =1"); <- this actually gave an interesting output.
But seems that I wouldnt be able to get away with only a line of code thist time here.
So what would be the best way to do this? (just imagine that I have an XML file with more than 2000 Rows)
|
|
|
|
|
No guarantees that this will work but you could try adding a BindingSouce component to your form and then the bindings become
datagrid.DataSource = bindingSource1;
bindingsource1.DataSource = dt;
BindingSource has a Filter property that you can use.
In fact, if you search MSDN for BindingSource.Filter, the example uses XML which should make getting your stuff to work a bit easier.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Fantastic, worked first time - ehm after I remembered that there is a difference between 1 and '1'. But thanks for the headsup on BindingSource.
Cheers,
|
|
|
|
|
Hello sir
I need to convert excel file into image file using c#.then send me sample code for converting word file into image file. Please send me immediately.
Thanks and regards
Vivek
hi
|
|
|
|
|
Member 4388360 wrote: Please send me immediately.
Upon receipt of 500 pounds sterling I'll send you the code. Until then, go to rentacoder.com. This is not the place to demand code.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Member 4388360 wrote: Please send me immediately
You are joking right?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Here's some sample pseudocode:
* Open xl file
* Show messagebox "URGENTZ! PLZ PRS PRNTSCRN! KTHXBYE!"
* Paste into bitmap
* save dat shizzle
|
|
|
|
|
Hi, im trying to Open multiple Ms Office files like Excel,PowerPoint & Word in my webBrowser, it works fine when im using Ms Office 2003 in other pc, but when i try to run the same application in another pc having Ms Office 2007 then instead of showing the MS Office file in webBrowser, it Opens the file in Ms Office. Does anyone know the solution to overcome this problem..
thanks in advance
|
|
|
|