|
Michael Sync wrote: ut i think that checking the extension might be more easier than checking the fist four bytes of each file, isn't it?
The first four bytes is an example off the top of my head. It's not real, Word doesn't do that. But, it may well do *something* to mark it's files.
And yes, checking the extension is going to work 99% of the time, and is a lot easier to do.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
aravinda777 wrote: i handled identifying non-images
non-images files means "*.txt, *.dll, *.exe"?? How did you handle identifying those file type without checking the extension??
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
In fact i am using the image to be displayed in a picturebox. When I try non-images, it gives an OutOfMemoryException.
This way I can identify non-images.
|
|
|
|
|
There is no general solution to identifying a file's type; new file types are
created every day.
If you are only interested in whether it is a loadable image, then try to load
the image, and live with the possible exception.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Maybe you will find this site useful:
http://www.wotsit.org/
Greetings, Thomas
|
|
|
|
|
You can check only the extension but it might be incorrect. If you want tighter control then look for magic number[^] in that file
|
|
|
|
|
Hi All,
I facing a problem which i have described briefly in the following paragraph.
Let me tell you a scenario where in the user has to choose any kind of dll he wants, rather be .Net Dll or Native Dll for a connection to his server.
In that he knows the function to Invoke.
I need to write a common user interface to invoke any kind of dll, based on the choice of the user. Is that possible ?. If so help me regarding the stratergy that i have to use or any examples of such accomplishment.
FYI
I know one software which is doing to most of the Dll's.
Thanks in Advance
|
|
|
|
|
You can late bind to .NET dlls, I'm not sure what you can do about native dlls, without having the pinvoke code already in your app.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
There are some articles here on cp which show you how to invoke function from a native dll without pinvoke code in the source.
|
|
|
|
|
hi, i am dealing with a stock market app, which is developing in c#.......... for trade purpose i want to use the QuickFix Protocol........ i was searching for sample codes for the same.... if any one have any idea pls contribute.............
My small attempt...
|
|
|
|
|
|
I had write code on text_change event of richText box in C#.net for wordwrap.
When i created the project and tested it its working fine, so i copy it make exe. Now problem is its showing some problem. so i check this code with oroginal code. In original code its working fine, but in copied code it showing problem.
The problem is like, after 3-4 line, at end of line its giving space in 2 letter like "Him" as "H i m", and adding "/n"at end of text.
Here maxLength is variable for no. of chracter like 65,66 etc per line, And if there is somthing wrong with code then plz help me.(not mismatch of { })
I want to know:
1. Code is for text_changed event & exact same in both, So why it like this?
2. Its only for text_change event and I dont think it has any relation with any other project part, i m using the text but after it has been put by the user.
The code for event is:
<br />
private void txtBody_TextChanged(object sender, eventArgs e)<br />
{<br />
<pre>if(tbWordwrap.Pushed)
{
string[] tempArray = new string(txtBody.Lines.length);
tempArray = txtBody.Lines;
int Prevsel = txtBody.SelectionStart;
string Op = "";
int maxLength = cINI.dbUtils.Pref.DefaultEditorWidth;
bool change= false;
for(int cou = 0; cou < tempArray.Length ; cou++)
{
if (tempArray[cou].length > maxLength)
{
string words = tempArray[cou].split(' ');
int currentLine Length = 0;
string currentLine = "";
foreach(string currentWords in words)
{
if(currentWord.Length > 0)
{
if(currentword.Length >= maxLength)
{
Op += currentword.Insert(maxLength, "\r\n");
break;
}
if(currentLineLength + currentword.Length + 1 < maxLength)
{
currentLine += currentword + " ";
currentLineLength += currentword.Length +1;
}
else
{
Op +=currentLine.Insert(currentLineLength, "\r\n");
currentLine = currentWord;
currentLineLength = currentWord.Length;
}
}
}
if(currentLine !="")
Op += currentLine;
PrevSel++;
change = true;
}
else
{
Op += tempArray[cou] + "\r\n";
}
if(change)
{
txtBody.Text = Op;
txtBody.SelectionStart = prevSel;
}
}
}</pre><br />
<br />
<br />
-- modified at 1:11 Wednesday 22nd August, 2007
|
|
|
|
|
best guess, the control is different sizes on the two forms, and so one version is showing up bugs in your code that are not evident in the other version.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi techies,
m working on the student management project (School) on C# 2005 and sql 2005 (windows application), i completed 80% , it can
create class , add section , edit student seats in particular section, add subject, add subject to the
particular section, registration of the student acccording to the class and section also display vacant
seat while registration, create first term result , second term result and final term, it can give
grace if student flunking( max 20 marks) , all result are in datagridview , but now i stuk while
printing it , i want to print the datagridview with form control(text box and label) coz it contains the
student information. so any one gimmme favour. (it shud b include print preview , page setting, and
print dialog) .
<<tech-prog>>
|
|
|
|
|
I think here[^] is the thing at CP that you want.
Mujtaba
"If both of us are having one one apple each and we exchange it, at the end we both will have one apple each. BUT if both of us are having one idea each and we exchange it, at the end both of us will be having two ideas each."
|
|
|
|
|
HI,
I am trying to write an SQL update query with c# code.
This is my situation.
I have a number of winforms and a sql server database. On one form I have drop down lists which are populated with the database rows by table adaptors.
This is what I need to do.
User selects a name from the drop down and clicks update which opens up a new form (class). In this new class I need to write an update statement to say update employees where '" + empNamecomboBox.Text.ToString() + "'. Basically to make sure we only update the selected employee, I want to say where the previously selection has been made. The only thing is I can't reference empNamecomboBox.Text because it belongs to another class.
Can you please helpe me? I've only got a few days to complete this.
Siann
|
|
|
|
|
So, basically you want to pass the string in question into the constructor of the new form, so that it knows where to look.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well I was told to use empID which is the primary key to pass to the constructor like this. But then I tried the same update statement to no evail. I have only been programming for 2 months. Do I use empID somewhere in the update query?
public UpdateEmployee(int employeeID)
{
this.employeeID = employeeID;
InitializeComponent();
}
public int employeeID;
|
|
|
|
|
falles01 wrote: public int employeeID;
Why on earth is this public ? If you've been given this code to work on, the people you work with are no better skilled than you, which does not bode well for your future.
Yes, you should be using this variable, instead of blindly copying code that relies on a control that's in another form. And, if you can't work that out, then you have some learning to do which excludes you from being able to write code that anyone should be expected to pay for.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
string sql = "UPDATE employees SET Firstname = '" + employeeTextBox.Text + "' Where EmployeeID = '" + employeeID + "'";
I am assuming the textbox is on the second form, therefore that control is correct ? Also, employeeId is an int, why is it stored as a string in the database ? If it's not, then change to this:
string sql = "UPDATE employees SET Firstname = '" + employeeTextBox.Text + "' Where EmployeeID = " + employeeID;
Note, I made a typing error, and so I lost the name of the textbox, and just made something up, you may need to fix that, to make it all work. The brackets are superfluous in either case.
And again, this is open to injection attacks. That means, someone can enter an employee name which erases your entire database.
Is this an assignment, or is it paid work ? If it's an assignment, I apologise for being a bit harsh previously, but if you've been given this code and told to work on it, that sounds like a job task. And, if that's true, you need to make the code more secure ( an assignment obviously is not as important, at this stage of your learning curve )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This is a project that I am doing to help me learn but will also be used by our department if it is good enough. Please note I get paid the worst wage in the world so don't worry about that! The guy next to me has been told to help me out but he doesn't really like helping out so he quickly showed me the overloaded constructor and when I told him it doesn't work he didn't really continue helping. he has had 10 years coding experience. I thought it was a little harsh considering I never liked programming and I'm really trying to give myself the confidence that I'm good enough, so that definitely shot me right back down again. I also read on the forum for that people aren't supposed to write abusive things like that to you people, but it was the other way around.
rEgardless, thanks for your help.
|
|
|
|
|
OK - two things disturb me in the industry right now
1 - people in places like India, who can't realy code, but come here for help when they take jobs at $2 an hour
2 - people who are not trained to code, being pushed into doing it by their bosses.
My responses were based in part on my assuming that you were in category 1. Again, I apologise. In the second case, it's the bosses who I am mad at, not the people who are stuck with the job.
falles01 wrote: The guy next to me has been told to help me out but he doesn't really like helping out so he quickly showed me the overloaded constructor and when I told him it doesn't work he didn't really continue helping.
Talk to your boss. If you're being expected to learn to code on the job, and they told someone to teach you, then they will hold *you* accountable if you don't complain now, while they expect that you're working on it quite happily.
falles01 wrote: I'm really trying to give myself the confidence that I'm good enough
Programming isn't that hard, I'm sure you are 'good enough', it's just a question of learning, and, more correctly, you would ideally learn without being under pressure to create a product that was going to be used. My first two years of programming, looking back at anything I had written 3 months prior would make me cringe. But, if this is what you're stuck with, we're certainly here to help. Just make sure the guy who is assigned to helping you is also doing what he's paid to do, instead of relying on a bunch of unpaid help, which, by definition, is less likely to be there absolutely when you need it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks. NO I am a good looking girl from Australia who has not got a personality for programming . ha ha, but I want to become a Business Analyst as I have an IT degree but I am a people person, so this will help me in the long run.
I also don't want to dop the guy in because he helps me sometimes, but my bosses also told me to work things out on my own. They don't like many questions here which is why I am seeking for other help. It took me 8 hrs to work out a problem yesterday that should've been so easy.
Thanks
|
|
|
|
|
falles01 wrote: They don't like many questions here which is why I am seeking for other help.
It sounds to me like they are not good people to work for. There's NOTHING wrong with asking questions, and everything wrong with NOT asking, when people around you are assuming you're doing fine.
falles01 wrote: It took me 8 hrs to work out a problem yesterday that should've been so easy.
Yeah, I've spent three nights on a problem like that ( learning WPF, a new framework ). It happens. I am in Australia too, so there's always at least one person on the boards who can help you, when you're at work.
The world needs more BAs who have some idea how to code, I hope it works out for you.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Also, I wrote all the code myself from scratch. It has taken me 4 weeks so far. They gave me no code. The guy next to me just told me to use that small portion I gave you in order to reference the other class.
|
|
|
|
|