|
No... I want to open file whatever it is.
The main purpose is to open file like UltraEdit32 or somethine like that (hex editor).
So it can open every file and read it as a binary.
but somehow my program miss some hex like i said before.
thanks
Training makes perfect....
|
|
|
|
|
If you want to create an app that can read all file types, you must use
binary file operations, not text operations.
Text operations work for text files only, binary operations work for all
file types.
So you should use the BinaryReader class, you should not use anything that
is text oriented such as:
StreamReader.ReadLine()
File.ReadAllLines()
File.ReadAllText()
FileInfo.OpenText()
...
that is everything that has "Text" or "Line" in its name, or returns
a string or a char or a char[]. To read arbitrary data, you need a byte[].
If you decide the byte[] represents text after all, you can try and decode it using
the Text.Encoding class
MSDN holds an article "How to: Read and Write to a Newly Created Data File"
that should be of interest to you.
|
|
|
|
|
Life as a Coder wrote: But somehow it missed some characters.
No, it didn't. A unicode file starts with a BOM (byte order mark). That is not text, but a code that represents how the file is encoded.
-- modified at 11:04 Saturday 4th August, 2007
However, the bytes at the beginning of the file doesn't match any of the existing byte order marks. I believe that Mark has the correct explanation, and that your file simply isn't a valid unicode file.
---
single minded; short sighted; long gone;
|
|
|
|
|
0xD8FF is a 'high surrogate' in UTF-16. It represents the first of a two code-unit pair that encodes a character outside the 16-bit Basic Multilingual Plane (anything over U+10000). Because it's not followed by the second code unit of the pair, a low surrogate, it's simply discarded as being illegal.
'Encoding.Unicode ' really refers to the 16-bit scheme of encoding Unicode called UTF-16 or UCS-2. See UTF-16/UCS-2[^] on Wikipedia.
As the others have said, use a binary stream class, e.g. FileStream , and a method of reading that returns a byte array.
|
|
|
|
|
Hi I am developing a C# windows application in .net1.1
In this i have a form, in which i am taking the input parameters, if the parameters are valid i am passing the paramers to a method which is in another class. while passing the paramers i am disabling some buttons on the form. After completing the process i want to enable the buttons on the form from the class.
Is it possible to enable controls on the form from a class.
Thanks in Advance
Ramu
|
|
|
|
|
Ramu.M wrote: Is it possible to enable controls on the form from a class
yes
|
|
|
|
|
plz tell me how to do it? (Any guidelines of code)
Thanks for your reply
|
|
|
|
|
The other class must know about the form - so you must pass details of the form to the other class (remember, forms are classes too) somehow. Then the class can access the form. You must provide a mechanism on the form to receive the request
class MyForm : Form
{
...
public void DisableControls()
{
}
}
class MyOtherClass
{
private MyForm myForm;
public MyOtherClass(MyForm myForm)
{
this.myForm = myForm;
}
public SomeMethodThatNeedsToDisableTheControls()
{
...
myForm.DisableControls();
...
}
}
Does this help?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
If you hold a reference to the form, you can manipulate everything on it that is
declared public, as in myForm.myButton.Enabled=true;
But it is considered bad design to make controls public, since everyone holding
the reference (myForm) can also replace, resize, move, hide, ... said control.
In fact, it is almost always wrong to provide public fields, only methods and
properties should be candidates for the public attribute.
An acceptable approach is:
- keep the controls private (or protected) to your form class;
- provide public methods (or properties) inside your form class, that offer
the required functionality to the outside world, no more, no less;
- pass the form's reference to your class and have it use the public methods
or properties.
And if you are familiar with delegates, they offer the best approach. It basically
means your form creates a delegate (that's like a function pointer connected
to the form's object), so now it can pass that delegate to your class, without
even having to pass the form's reference itself. That is encapsulation, provide
as little as possible, just give what is absolutely necessary.
|
|
|
|
|
Hi .
Yes you can , something like following code :
<br />
public class ControlForm<br />
{<br />
public static void EnableTextBox()<br />
{<br />
FrmTest frmTest = new frmTest();<br />
frmTest.txtName.Enable = true;<br />
}<br />
}<br />
Important :Set your control modifier property to Internal or Public
Bad Programming :Don't try to do this . It's not a smart coding .
DMASTER
|
|
|
|
|
Even you can use Delegates for Enabling/Disabling controls of the Form. The Delegate will remove the requirement to declare control objects (Text etc) public.
Manoj
Never Gives up
|
|
|
|
|
Manoj Kumar Rai wrote: The Delegate will remove the requirement to declare control objects (Text etc) public.
Text is a parameter on the control. You cannot make that public. You must make the control public, or create a new property on the form that proxies for the control's property.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Yes Yes, You are corrrect. I meant TextBox there.
Manoj
Never Gives up
|
|
|
|
|
Thank you very much.
Ramu
|
|
|
|
|
I'm already say it .
So , what ...
DMASTER
|
|
|
|
|
I want to genrate a log of event in text box?
How can i do that?
Actually i am regularly looking up an event and when event is being raised then its appropriate message is get printed in text box.
But it get printed on same text(of event), means previous text erased and new text(of event) get printed?
I want every event text appears like log,
I tried Environment.NewLine but no use?
How to acheive this.
Plz help
|
|
|
|
|
humdumof wrote: I tried Environment.NewLine but no use?
How did you try ?
tb.Text = tb.Text + Environment.NewLine + log;
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?
Actually i m coding like
tb.Text = event + Environment.NewLine;
not adding previous text?
After writing like this problem solved.
tb.Text = tb.Text + event + Environment.NewLine;
Thanks for helping.
|
|
|
|
|
Hi All
After trying to do a system restore I noticed that I was not able to load or execute my C# project. It seems Window removed the .sln file. Is there a way I could recreate it and revive my project?
|
|
|
|
|
Open the csproj.
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 )
|
|
|
|
|
Sadly, that file is gone as well. I don't understand why it was deleted in the first place. The .resx file is missing as well so even though the form1.designer.cs file is there I can't open the design layout. All I have are the .cs C# program files. I guss I would need to recreate the csproj file as well as the resx file. Can that be done as well?
|
|
|
|
|
|
Hi everybody,
for ticker(scrolling text from left to right or from top to bottom rotated) I have used html file with java script. and am showing this in a browser control in my C# application. This script uses cookies, hence it uses around 30% CPU utilization, which is very high.
Please suggest something, which will take low CPU utilization.
Thanks
and best regards
Rabindra Patra
|
|
|
|
|
Well, pretty much any other way would be better. I'm sure there are controls on this site, or just write one, derived from the label control.
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 for the reply.
Actually, I need some more features. For the time being I have done the thing. But how can I give Fade in effect, or some other effects?
I thing using Direct X it can be done, But I am not getting how to do it.
|
|
|
|