|
Hi Ed,
Thanks for the quick reply.
You are correct: use the HtmlElement class and GetAttribute() method to get the image size with width & height as parameters. However I was referring to the "file" size (in bytes) of the image file. I know IE stores the webpage files in "Temporary Internet Files" folder as local cache but somehow programmatically it (OS?) does not allow the files to be read. However you can manually see these files using Windows Explorer.
Any thoughts?
Thanks.
dan215
|
|
|
|
|
How about:
string uri = @"the image filename here";
WebRequest request = WebRequest.Create(uri);
WebResponse response = request.GetResponse();
Console.WriteLine("Content.Length={0}", response.ContentLength);
You can use HtmlElement.GetAttribute("src") to get the path to the image. I shouldn't think that this re-downloads the file but you never know.
[mod]It doesn't unless my 512k line just downloaded 650 meg in 1/2 a sec [/mod]
Ed
-- modified at 19:31 Monday 17th April, 2006
|
|
|
|
|
Unfortunately, response.ContentLength only gives you the "HTML text" size. It does not include the image(s).
dan215
|
|
|
|
|
If you pass the image file URI which you want to get the size of then it will. I tested this on a PDF hosted on our website.
Ed
|
|
|
|
|
Hi Ed,
Thanks. You are correct. My dilemma is I'm using WebBrowser control first to navigate to the webpage to get all the images names via HtmlDocument/HtmlElement classes. If I use WebRequest/WebResponse, I'm essentially doing two requests from the server. I'm thinking if there a way to just do these things once. I don't have to use WebBrowser control but it helps in easily parsing the desired attributes.
Appreciate your help. Things are looking up!
dan215
BTW: I tried accessing a local image and I got a "401" not authorized error message.
-- modified at 13:51 Tuesday 18th April, 2006
|
|
|
|
|
dan215 wrote:
BTW: I tried accessing a local image and I got a "401" not authorized error message.
Is this a problem or just a point you cared to share?
Glad to see things are sorting themselves out.
Ed
|
|
|
|
|
Well, it was a problem but I got it fixed by changing the Authentication Method of my localhost webpage from Integrated Windows Authentication to Anonymous Access just for testing purposes.
I haven't figured out yet how to get the byte size in 1 request but 2 requests is ok for now.
Thanks a lot Ed.
dan215
|
|
|
|
|
Unless you already know the uri of the image/file you want to get the size of you cannot make it in one request because you have to have one to find the location of the file (i.e. a request to the html file to find the image path) and then a request to the image file for the file size.
Ed
|
|
|
|
|
I agree. Another way I thought I could do was to read the image file info from the Temporary Internet Files folder but I can't use the FileInfo class since XP does not seem to allow any file in that directory be read except desktop.ini. If I can circumvent this that would resolve the issue.
Any ideas?
dan215
|
|
|
|
|
dan215 wrote: Any ideas?
Not really, apart from that my view of accessing the Temporary Internet Files is a bad idea on the whole. There are too many ifs and buts.
The thing which I should be improved is trying to eliminate the WebBrowser if you're simply using it for accessing the html to get the filename and not actually displaying it because my guess it'll be very resource hungry.
If you know that the image paths will be specified in the html page then it'd probably be more efficient to make a WebRequest or use WebClient to "download" or read the file and then use a simple parser or regular expressions to extract the image file, this way you're not creating a UI control and then not displaying it.
Just my two pennies
Ed
|
|
|
|
|
I agree with you.
Thanks.
dan215
|
|
|
|
|
That's good to know
Ed
|
|
|
|
|
Hey guys, I have to tables and I want to make a selection from both tables
Table 1: Customer >> Name and number (my main table)
Table 2: Order >> Order
with the select command i select them, not I want to show it in DataGridView, but i can fill data gried with one table
DataGridView1.dataSource = MyDS.Tables["Customer"];
but when I fill in the DataGridView, It authomatically adds the new Row from Order Table(i want to change the header but its not possible because it brings it driectly from database).
I used this command to add a column in my dataSet
MyDS.Tables["Customer"].Columns.Add("Order");
what I dunno how to do this, to show the data in the column Order from Order table in my new Column that I have created.
Mr.K
|
|
|
|
|
You're being a little vague, so hopefully I'll be able to get some clarification. Are you trying to join two tables and then display the resulting join in a DGV? If so, can you give us the query string that you use to retrieve the data. Also, have you stepped through your code and ensured the query returns what you want?
|
|
|
|
|
I fixed that Problem, I have this question
we have this command for DataGrid
dataGrid1.SetDataBinding(MyDataSet, "MyTable");
Do we have the same command for DGV ? Or something equivalant that does the sam thing ?
Mr.K
|
|
|
|
|
I was wondering if it would be possible to implement a LinkHover event on the rich text box control. It already has a LinkClick event, but no facilities to offer a tooltip on LinkHover. I'm assuming it is possible, as on mouseover a link the cursor changes, but i'm guessing it will need some COM work.
Cheers
Tris
|
|
|
|
|
Why don't you try deriving from the RichTextBox and overriding the OnMouseMove method. You can then use RichTextBox.GetCharIndexFromPosition to get the character under the cursor and if it's a link then fire your custom LinkHover event (of course that's a simplified plan but it should get you started).
The only trouble I see at the moment is finding out the indexes of the links. I can't seem to find anything which lists them which suggests they are handled internally by the control.
So if you can solve the last problem then you're away (also this solution is managed rather than COM Interop)
Ed
|
|
|
|
|
Ok, I have one form when I click a button, I want my existing from to be minimized and a new form to be opened.
How can I do that ?
Mr.K
|
|
|
|
|
|
Well, if you want to minimize a form created in your program, this is a pretty easy task:
1. Just add a method to the Click event of the button. (Designer can even do that for you)
2. In this method you set the WindowState Property to Minimized:
this.WindowState = FormWindowState.Minimized;
To open a new form just add MyForm.Show(); to your method for the click event.
Greetings.
-- modified at 5:07 Tuesday 18th April, 2006
|
|
|
|
|
Right, you can change the WindowState property to come true.
Plz try it!
------------------------------------------------
I Love the Win32 and MSN, Because it's Universal & Facility !!!
|
|
|
|
|
Hello,
If I have DataTable available, is there a way of getting the TableAdapter for the given table, so I can update it?
Thank you.
|
|
|
|
|
hallo every one,
i have create a program that show my a table in my DB.
until here all is good ... but i want it to be able to update the table
without me having to write the Rows or the column so the program can work
with any table even if i dont know everything about the table.
can some one help my?
thanks 
|
|
|
|
|
is there a special SQL command that can help my?
|
|
|
|
|
i have problem in treeview control that is when i selected treeview folder the contents of selected folder will not display on right side like a Windows Explore.Please send me code in c#.net for this problem.
|
|
|
|