|
IsMatch returns a boolean whether it found or not your regex expression in the input string.
The correct way to use regex would be with this basic regex
Regex reg = New Regex("""(.+?)""", RegexOptions.IgnoreCase | RegexOptions.Multiline);
MatchCollection mtc = reg.Matches("input string");
this will return a MatchCollection which u can loop through to get every match of the pattern in the input string. Use the GetEnumerator method of the above MatchCollection to loop through the matches.
Code? Yeah i love it fried together with a glass of wine.
|
|
|
|
|
My problem: reading bits from a file and manipulate them.
So I have to get the 0's and the 1's from a file in an array or something, adjust them and make a file again with them. Is this possible? You guys could help me with some example code or some useful function names. I would really appreciate that
|
|
|
|
|
load bytes from your file and manipulate them using System.Collection.BitArray, convert again to bytes then save to file.
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
yes it helps, but
how can I convert BitArray to byte[] ?
BitArray myBitArray = new BitArray(myBytesArray);
byte[] myNewByte = ... ?
|
|
|
|
|
This should work....haven't really tested it.
String path = "path to your file";
System.IO.StreamReader reader = new System.IO.StreamReader(path);
String data = reader.ReadToEnd();
byte[] buffer = Encoding.ASCII.GetBytes(data);
System.Collections.BitArray bits = new System.Collections.BitArray(buffer);
Hope this helps
|
|
|
|
|
yes it helps, but
how can I convert BitArray to byte[] ?
BitArray myBitArray = new BitArray(myBytesArray);
byte[] myNewByte = ... ?
|
|
|
|
|
Check msdn for BitConverter. That should help.
|
|
|
|
|
Hello! I'm new to C# and .NET. Most of the developement I've done lately is in PL/SQL and/or Perl, so C# is "a bit" of a change for me. I've got an architecture question first which I'm sure will lead to more questions.
I work for a company that has hundreds of remote devices around the country. I need to write an app that, in a nutshell, reads the details of these devices from a database, contacts them via a phone call using a modem pool, downloads a data file, then updates certain fields in the database.
I'd like opinions on whether this is a good way to do it or not:
I'm thinking of writing two separate apps that communicate via remoting. One app (the client) would be the one that 'talks' to the database. It periodically reads the database to see which devices need to be contacted. It would be multi-threaded so it can initiate multiple contacts at once.
The second app (the server) would be responsible for controlling the modem pool (up to 20 modems/phone lines). It would take a request from the client, contact the device, and get the data file, then respond back to the client with the status of the call (sucess or failed and why failed).
Does this sound like a good way to proceed? Any hidden 'gotchas' I should know about? Threading, remoting, dialing a modem, etc, is all new to me so this should be..... 'interesting'.
- Dave -
|
|
|
|
|
I'm getting crazy...
I've tried to run through this.Controls
...but it only found the MenuStrip and ToolStrip. The names of the items like "mnuOptions" weren't listed.
So I've tried stupid like this.components.Components.GetEnumerator()
...and got only one element.
All objects can be accessed by typing this. and the name of object. Even those of the MenuStrip or ToolStrip. But at runtime they can't be accessed by this.Controls["menuItemXY"] .
I know about recursive getting controls. But this solution doesn't get the items of a MenuStrip.
Is there any solution to get really all objects in a form at once and without switching the type of object?
modified on Thursday, November 13, 2008 11:16 AM
|
|
|
|
|
All controls have a property called Controls which return subcontrols so you need to write a recursive method that loops on all controls on the form and calls itself for every control it finds at any stage.
|
|
|
|
|
You'll have to walk the hierarchy of Controls as each Control itself has a Controls collection. For menus, groupboxes, and things of that sort that can contain other controls you cannot access the internal controls from the Form's Controls collection directly; rather, through the Controls collection of the container itself.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
I found a good and understood answer to this question: Items of ToolStrip and MenuStrip aren't controls, so that's the reason why it doesn't work to run through the control collection, even if it's recursive.
I have to choose the right handling after getting the type of control and run through the type of what ever is in it. For me it's not an ideal solution, but there isn't a general solution for all types, I guess.
|
|
|
|
|
Hi,
I have developed an application that processes WAV (PCM) files in C#. My issue is that it is possible to get compressed wave files in GSM format as well. What can be the best way to convert them to PCM, programmitcally, so that I can use them with my application. There seems to be a few options like using winmm.dll or audio compression manager. Unfortunately I couldnt find relevant resources for properly using these in C#. Any pointers in the right direction will be much appreciated. Thanks
Kind Regards,
Fahd
|
|
|
|
|
Just done a quick google search,and is seams like SOX[^] is the easiest.
Apparently to do .gsm to wav you just need
sox -V in.gsm -s -w <code>out.wav
where in.gsm is your gsm file and out.wav is the new wav.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hi
Thanks for your reply Dave, but I want a way to do it within my application. My application is a multithread app that will be handling multiple wav streams coming in so probably can't use the sox exe as well. Is there any other way?
regards
Fahd
|
|
|
|
|
You should be able to use the exe using Process.Start / ShellExecute either passing the commands as arguments, or creating a bat file with the commands in and running that from your app, or creating a wrapper around the relevant dlls (if there are any?).
If none of those work, or don't appeal - the source code is available (in C, not C#) for sox. You can study that and write your own .net implementation.
Either one could prove to make an interesting subject for an article!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I have 2 threads, one application thread and the workflow foundation thread. My application thread now throws an exception, but the try-catch-block is in a method that is called in the workflow thread. The problem is, this exception is not caught in the try-catch-block. I am wondering if it is possible to somehow marshal the throwing of the exception to the workflow thread. Does anyone know this?
|
|
|
|
|
I have some javascript with activeX object. For setting parameter value of this activex object this code is used:
ObjectCache = new ActiveXObject("Shell.ObjectCache");
ObjectCache("variableName") = "value";
How can I write my assembly that will work with code above?
I know that assembly uses default method if this helps.
|
|
|
|
|
The ShowDialog(IWin32Window) may take a Form object instance as its parameter.But the Form doesn't implement IWin32Window interface.
Anyone can explain it?
Thank you very much!
|
|
|
|
|
Form class inherits from ContainerControl class which inherits ScrollableControl which in turn inherits from Control which ...
I hope you can continue from here and find out answer to your question
|
|
|
|
|
Thank you very much for so quick reply!
|
|
|
|
|
You are welcome
|
|
|
|
|
You're saying that the Form class doesn't implement the IWin32Window interface?? Uhh, yes it does. Form gets it from the Control class that Form (eventually) inherits from. Here's the entire inheritance tree for Form:
Class Object
Class MarshalByRefObject
Class Component (IComponent, IDisposable)
Class Control (IOleControl, IOleObject, IOleInPlaceObject,
IOleInPlaceActiveObject, IOleWindow, IViewObject, IViewObject2,
IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage,
IQuickActivate, ISupportOleDropSource, IDropTarget, ISynchronizeInvoke,
IWin32Window, IArrangedElement, IBindableComponent,
IComponent, IDisposable)
Class ScrollableContainer (IArrangedElement, IComponent, IDisposable)
Class ContainerControl (IContainerControl)
Class Form
|
|
|
|
|
Dave ,thank you very much for so clear explanation!
|
|
|
|
|
Dear All:
How to set the background color of the Scrollbar of DataGridView with C# in the WinForm ?
Many thanks!
|
|
|
|