|
Your explanation is great. I know I am using a byte array (I don't think a bit array exist), but how do i go about accessing the bits of each byte in the array?
|
|
|
|
|
|
You can use the BitArray class to treat the array of bytes as an array of bits.
byte[] data = File.ReadAllBytes("C:\Folder\TheFileToRead.ext");
BitArray dataAsBits = new BitArray(data);
See BitArray Class[^]
Note the order of the bits in the bytes!!
|
|
|
|
|
Upvoted ! At the time I wrote my response to this thread, Richard's reply was not available here, which is becoming all too typical: there is often a gap of hours before content on QA and Forums shows up, and, yet, other parts of CodeProject seem to be updated instantly.
Had I seen Richard's response, I would not have posted.
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
|
|
|
|
|
I can't understand what you are trying to do here:
1. you get a Directory, and then you iterate over all its files setting a variable to the current file length: which means the value of 'Totbyte is always going to be equal to the length of the last file read.
Did you mean to make a total of the length of all files ? in which case you should have: Totbyte += ap.Length; ?
2. then you create two temporary files, and check if one of them exists, and read its bytes into a byte[], which makes no sense, since the temp file will have no content.
Isn't it the case that the file (files ?) you want to read have something to do with the first part of your code, where you create an array of files from a Directory path ?
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
|
|
|
|
|
Ideally what I am trying to do is copy of a file off my desktop in an Array of Bits (not Bytes). Can you please explain how this can be done?
|
|
|
|
|
Richard Deeming already gave you the answer to this.
You could use the BitArray class[^] to give you access to the bits in each byte, but it's not exactly what I would call "efficient".
You would still have to read the file into a byte array and then pass the byte array to the BitArray constructor.
|
|
|
|
|
I really should have read all of the comments before posting my (redundant) suggestion of BitArray....
|
|
|
|
|
Dear All,
I am using Visual Studio 2010 ultimate, C# language and MySql as backend database.
I've a Voucher Form, which is Master Detail. After user enters voucher data, he save the data in database by clicking save button. Now I need to add a post button, which when click perform a update to Voucher record and mark it as POSTED. This is not an issue as it simply required an Sql update statement.
What I need is a way, that after POSTED is marked, no one can edit the record, even when it is search by any user. What is the best way to do it? Are programmers do it by setting readonly property of controls true/false? Or there are other options available?
Any ideas/suggestions/samples much appreciated.
Best regards
Ahmed
|
|
|
|
|
ahmed_one wrote: What I need is a way, that after POSTED is marked, no one can edit the record, even when it is search by any user.
Can this be clarified a little please? There are a few different potential problems here. First off, what do you mean by "no one can edit the record"? The database admin is going to be able to edit the record, one way or another. If you mean users should not be able to edit the record, then you are in control of what they do in the application, so you must have enabled the ability to updated? I don't know why searching alters the record (as your comment seems to suggest) - this sounds like something is very wonky to me, or you don't mean database record. It might be better to expand on your question.
ahmed_one wrote: Are programmers do it by setting readonly property of controls true/false? Or there are other options available?
Yes, it is possible and normal to do this (normally a check-box). The other options depend on what you need so no-one can answer that for you, you might want to consult the people you are writing the software for.
|
|
|
|
|
Keith Barrow wrote: ahmed_one wrote: What I need is a way, that after POSTED is marked, no one can edit the record, even when it is search by any user.
Can this be clarified a little please? There are a few different potential problems here. First off, what do you mean by "no one can edit the record"? The database admin is going to be able to edit the record, one way or another. If you mean users should not be able to edit the record, then you are in control of what they do in the application, so you must have enabled the ability to updated? I don't know why searching alters the record (as your comment seems to suggest) - this sounds like something is very wonky to me, or you don't mean database record. It might be better to expand on your question.
By "No one can edit the record" I mean users. Database admin surely can alter the data. That's not a problem. At present, searching is not altering the record, my requirement is: when POSTED is marked users are restricted to Add/Edit/Delete/Update that POSTED record. This means when user use find function to display record (which is POSTED now) in Winforms, it should be locked for ADD/EDIT/DELETE/UPDATE.
|
|
|
|
|
It's been a long time since I've done any winforms, but in principal I'd:
- Extract the UI that allows viewing/adding/updating the record as a control.
- Set the control from above's enabled state to false - this will disable the control
- Show/hide buttons in the control as appropriate
Another option is to create two controls - one for add/edit the other for view only and display the relevant one. Depending on what you are doing, you can usually improve the user experience, though at the cost of extra work, so you need to balance these off with eachother.
|
|
|
|
|
Thanks for your reply,
Are there any option available via Sql, when user find the record, the find function should call a function which fetch data from MySql Db in read-only mode.
|
|
|
|
|
ahmed_one wrote: Are there any option available via Sql, when user find the record, the find function should call a function which fetch data from MySql Db in read-only mode. If you only "SELECT" data it will always be readonly. Simply don't update the data.
No, MySQL has no magic functions.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks....I will try this...
|
|
|
|
|
how do displayed word 360 view rotational
kumar
|
|
|
|
|
|
how to create continue rotational word
|
|
|
|
|
|
|
A standard textbox automatically rotates a word throught 360 degrees - it's just to fast for you to see, as rotating something 360 degrees brings it back to its start position!
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Sadly you see the result only, not the process...
Well, judging from your signature, you might see the process too, even if it is not visible to the rest of us.
|
|
|
|
|
I need to send sms from my windows application i tried with many dl and gateway but ended in vain pls help me
|
|
|
|
|
Google has lots of samples and links, try some of them. But if you have a problem with your code, then please provide proper details and explanation.
Veni, vidi, abiit domum
|
|
|
|
|
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang16393{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 6.3.9600}\viewkind4\uc1\pard\sa200\sl276\slmult1\f0\fs22\lang9\\hello \\\\ r u there \\\\\\\\ with your family \\\\\par
}
plz tell me how to detect text as : \hello\\ r u there \\\\ with your family from the given rtf file
|
|
|
|