|
That is a basic check. It will not work if a DOC file is named, say, XLS. To be sure, you have to look at the file header.
Cheers,
Vikram.
"I will put my new found knolage to good use" - Captain See Sharp.
"Every time Lotus Notes starts up, somewhere a puppy, a kitten, a lamb, and a baby seal are killed." - Gary Wheeler.
|
|
|
|
|
The right way to do this is going to be using the SHGetFileInfo Win32 API. You will need to retrieve the SHGFI.TYPENAME value.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Good day to everyone, can someone guide me on how to implement graphs (bars, lines, pies) on visual c#? Is it possible? I found some information regarding .net, but I really do not understand it that much. Thank you...
Oh yeah, very much appreciated if someone can also give me sources that helps a lot...
|
|
|
|
|
You can search that yourself, either with Google, or with the CodeProject search box on top
of this page. One of the many CP articles you may like is this one[^].
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Ü thanks, I actually search prior posting this message, but I did not search here just in Google.
Sorry I am new to this GUI.
|
|
|
|
|
Good day to everyone, can someone guide me on how to implement graphs (bars, lines, pies) on visual c#? Is it possible? I found some information regarding .net, but I really do not understand it that much. Thank you...
|
|
|
|
|
|
thanks, I just skimmed at it... Maybe I am gonna read it later. But it can still be implemented with just C# right? or it should be C# .net?
|
|
|
|
|
sins616™ wrote: But it can still be implemented with just C# right? or it should be C# .net?
You can't do one without the other. C# uses the .NET framework and cannot run without it present in some flavour.
|
|
|
|
|
all the coding will be on visual basic c# right? sorry for being ignorant.
|
|
|
|
|
Hi,
I found that, every object in .NET has this common method named GetHashCode(). Would you please tell me in simple words, what is this function for ? and what is the use of this function ?
Thanks.
|
|
|
|
|
Hi,
I haven't used it explicitly so far, but this is how I remember it:
every class should implement a hash algorithm, turning its data into a single number.
There are some rules, e.g. the result should be immutable (once set, it must remain what it is).
It is used by some classes, e.g. HashTable will call it to determine how/where to store
a reference; taking care of a well spread distribution improves the efficiency of classes
such as HashTable. If you don't (say you always return 42) then HashTable will still operate
correctly but much less efficiently.
Of course, if you suspect you don't need hashing at all, you don't have to worry; by
inheritance you'll get the default implementation, so you are set.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi, Thanks.
So, is it something similar to TypeConverter ? What I understand by TypeConverter is as follows: TypeConverter is a class that implements the functionality to convert a object data to a plain string value and vice versa. So, is HashCode is similarly convert an object's data to an Integer value and vice versa ?
Regards.
|
|
|
|
|
bashiwala wrote: is it something similar to TypeConverter
No:
- TypeConverter tries to preserve the content as much as possible, so there is a vice versa
conversion;
- GetHashCode() compresses an entire object into a single number, there is no way back;
the number indicates in which bin a HashTable would store the object for future reference.
A simple hash table for words is: look at the first character, and take the numeric value of its
ASCII representation. That's good enough to store a normal vocabulary, but it is worthless
if all the words you ever need start with the same letter.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi, I'm trying to write a receive loop in my socket class that will receive what data is in the buffer, call an event to let the user know that there's new data, and then receive the rest of the data. It kinda almost works; it receives much of the data, but seems to miss the last packet or two. Here is the code in the loop:
private void OnSockReceive(IAsyncResult ar)
{
try
{
int read = socket.EndReceive(ar);
if (read > 0)
{
OnReceive();
}
socket.BeginReceive(ReceivedData, 0, ReceivedData.Length, SocketFlags.None, OnSockReceive, null);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "OnSockReceive", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
ReceivedData is a global byte array of size 1024.
Any help would be greatly appreciated.
Thanks.
|
|
|
|
|
I know there is an article about this subject in this site.
But I couldn't get the idea, as I'm not that good at ASP.NET or java script
I have this webpage that needs log in.
<i><FORM name='fid' METHOD=post ACTION='/cgi/cgiwrap/blabla/blabla.cgi'>
<INPUT TYPE=hidden NAME=do VALUE='show'>
<INPUT TYPE=hidden NAME=cour VALUE='305'>
<table width=380 border=0 cellpadding=2><tr>
<td align=right> Year: </td>
<td align=left>
<SELECT NAME=year>
<OPTION VALUE=00 >2000 </OPTION><OPTION VALUE=01 >2001 </OPTION><OPTION VALUE=02 >2002 </OPTION><OPTION VALUE=03 >2003 </OPTION><OPTION VALUE=04 >2004 </OPTION><OPTION VALUE=05 >2005 </OPTION><OPTION VALUE=06 >2006 </OPTION><OPTION VALUE=07 selected >2007 </OPTION><OPTION VALUE=08 >2008 </OPTION> </SELECT></td>
<td align=left rowspan=3><input type=submit value=" FETCH "> </td>
<tr>
<td align=right> Student ID: </font></td>
<td align=left><input type=text NAME=id MAXLENGTH=7 SIZE=7></td>
<tr>
<td align=right> Password:<br><FONT size="-2"> </font></td>
<td align=left><input type=password NAME=pw MAXLENGTH=12 SIZE=7></td>
<tr height=8>
</table>
</FORM>
</i>
I have the username and password but I don't want to do it by myself, I want to do it automatically and get the source code after the log on.
In the article it says I can handle it POST methods but I don't know what to put into methods as a POST string.
So I have a textbox named as 'id' and another txtbox named as 'pw'. I want to set their values and (perform) click to a submit button that posts these information to '/cgi/cgiwrap/blabla/blabla.cgi' and returns a web page whose source I desire. What shall I do ?
Related part of the article's source code:
<i>// Add POST data (if present)
string strPostData = getPostData();
if (strPostData != null) {
ASCIIEncoding asciiEncoding = new ASCIIEncoding();
byte[] postData = asciiEncoding.GetBytes (strPostData);
req.Method = "POST";
req.ContentType="application/x-www-form-urlencoded";
req.ContentLength = postData.Length;
Stream reqStream = req.GetRequestStream();
reqStream.Write (postData, 0, postData.Length);
reqStream.Close();
}</i>
|
|
|
|
|
methhoo wrote: I know there is an article about this subject in this site.
Then you should post your question to the author of the article. He/she might have a better idea of what you are talking about.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Sorry to post this again, but I needed more help than I got. I just can not understand this for some reason. I see alot of things that pass a value of a textbox to another form. We'll it opens the second form when passing the value.
I need it to pass a string/value to a form that is already open.
I have two forms.
Form: EnterInformation
--> Contains listBox1 that will hold up to five phone numbers.
Form: Phone
--> Contains two textboxes and a OK button.
Now both forms are currently open. So you enter a phone number in textbox1
--> (501) 123-1234
Now enter a description in the second textbox.
--> Jacobs Cell
Put it in a string.
string PhoneN = string.Format("{0} ({1})", textBox1.Text, textBox2.Text);
which makes it: (501) 123-1234 (Jacobs Cell)
Now this will pass what is above to the listBox on the EnterInformation form.
Please help me on this, or direct me to a tutorial that talks about something like this directly. Thank you in advance!
|
|
|
|
|
Look at the article on this site by Colin Mackay about passing values between two forms. It is a really good one.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Thanks.. I will check it out
|
|
|
|
|
Noooo - please don't pass values between forms. Instead, consider using a suitable design pattern such as MVC to manage the interaction instead. Your phone number is part of the model; the forms are the views. Trust me - you'll be a better developer at the end of this journey.
|
|
|
|
|
I was looking at the article and I don't think that will do what I want it to anyways. I'm very confused on this. Mainly because the EnterInformation form is part of the access database. It seems like everyone passes it when opening the form as in Form form = new EnterInformation(string PhoneN). I cannot have the form reload like that because then the Fill will occur. I don't know if I explained that quite well.
I need it to pass the text to the EnterInformation (which is already open, and I do not want to perform a new EnterInformation).
|
|
|
|
|
I'll explain the MVC pattern and you can see how it is applied. Basically you have a datamodel which includes the phone number. There's a controller which is responsible for actually changing the value based on user input - and when the model changes, the attached views are updated by the controller. To do this update, you'd typically use an Update method which updates the view based on the values in the model. As a hint, you're probably going to need an event or two in here as well. I'm not actually going to write the code for you - you've got enough information now to do some research in google and have a stab at your version.
|
|
|
|
|
I think I get what you are saying... I will see what I can find.
|
|
|
|
|