|
Sure, but keep in mind that regular expressions are inherently slower than simple string parsing. If you will be using this regex several times, you should at least compile it. This will boost performance a bit, but it will still be slower than just parsing a string, especially in such an easy case.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Jose Fco Bonnin wrote:
@"0*[1-9][0-9]*"
WTF? Firstly, why not use @"\d+" ? And what is the purpose of the "prepended" zero's? And lastly, why test it again (not correctly even!) ? Very counter-productive...
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
if you use @"\d+" and your string is "aaaa1" the result will be true.
|
|
|
|
|
Oops, just forgot the line markers, should be @"^\d+$".
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Thank you Bonnin, it works fine. can u explain the whole stuff,
ie why we want 0,*.......
all i changed \p{Nd} instead of [0-9] and it works fine since i use unicode.
those who reponded to my query once again, thanks a lot.
|
|
|
|
|
Hi everyone,
I did not know where else to post this.
I am using MS XP Office Web Components in C# to generate an excel file using the spreadsheet component. I do not want to use the Excel COM object for various reasons.
My problem is that I could not find any way to set the header and footer property of a Worksheet object. In Excel you can set the header and footer for every worksheet. I wanted to do the same with the spreadsheet component in OWC10. However, I have had no luck finding an API for this.
If anyone has any idea on how to accomplish this, I would really appreciate it.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Greetings
I'm trying to create an CaptureBuffer object. When the constructor is called in run-time I get the following error: value does not fall within the expected range.
My code looks like this:
g = DSoundHelper.DefaultCaptureDevice;
Microsoft.DirectX.DirectSound.Capture c = new Microsoft.DirectX.DirectSound.Capture(g);
CaptureBufferDescription cbd = new CaptureBufferDescription();
cbd.Format = soundbuffer.Format;
cbd.BufferBytes = caps.BufferBytes;
cbd.ControlEffects=false;
cbd.WaveMapped=false;
cbd.ControlEffects=false;
cb = new CaptureBuffer(cbd,c); // Here I get the error.
Please help I'm stuck with this error for two days..
Kind Regards
Shimi
|
|
|
|
|
I'm replying for myself but I located the bug.
The caps object wasn't intialized!
Shimi
|
|
|
|
|
Hi
I am writing code which accepts an array of objects, converts them to XML and loads them into a dataset.
My problem is that when the XML is created, it does not contain an indication of the data types of the fields. As a result, all the data types of the columns in the dataset are System.String.
Is there a way to force creation of shcemea when creating the XML string?
Here is the code:
[Serializable]
[XmlType("MyClass")]
public class MyClass
{
[XmlAttribute("IntField")]
public int IntField;
[XmlAttribute("StringField")]
public string StringField;
[XmlAttribute("ByteField")]
public byte ByteField;
public MyClass() {}
}
string xmlString;
System.Xml.Serialization.XmlSerializer xmlSer;
XmlWriter xmlWriter;
MyClass myObj = new MyClass();
StringWriter sw = new StringWriter();
myObj.IntField = 1;
myObj.StringField = "a string...";
myObj.ByteField = 2;
xmlWriter = new XmlTextWriter(sw);
xmlSer = new XmlSerializer(typeof(MyClass));
xmlSer.Serialize(xmlWriter,myObj);
xmlString = sw.ToString();
// at this point the xmlString looks as follows:
//"
//<myclass xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" intfield="1" stringfield="a string..." bytefield="2">"
DataSet ds = new DataSet();
StringReader sr = new StringReader(xmlString);
ds.ReadXml(sr);
// At this point ds.Tables[0].Columns[0].DataType.ToString() returns System.String instead of System.32
|
|
|
|
|
XML serialization using the XmlSerializer always serializes to strings (that's all XML can contains) but deserializes the string back to the Types of the properties with which they map. When you read this XML fragment into a DataSet , the DataSet has no idea what it is reading and will assume that all the columns are simply strings.
In order to coerce the DataSet to use a schema, you can either create a DataSet schema using the DataSet designer in VS.NET, or just type one manually yourself and read that schema in with DataSet.ReadXmlSchema , then use DataSet.ReadXml .
An even better way is to create a strongly-typed DataSet using the VS.NET DataSet designer (right-click on project or project folder, select Add->Add New Item and select DataSet) and use that instead of DataSet :
MyDataSet ds = new MyDataSet();
StringReader sr = new StringReader(xmlString);
ds.ReadXml(sr); This way, the DataSet object is initialized with all the necessary table and column information and you can refer to columns by name without having to cast to the necessary data type.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i see some third party menus and microsoft access place controls in menu like textbox control
how can i do that in c#
i mean if i have to use hooking
hook what ?
thanks in advance
|
|
|
|
|
I tried to ask this earlier, but something went crunch.
I want to have my application start each time the computer boots up. Anybody know how to do this or where to find out how?
Thanks in advance
Joe
|
|
|
|
|
pardue,
You can use windows registry, all you need to do is just create a string value pointed to your .exe file in the following windows registry key :[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
for example:
(For all users)
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"myApp"="\"C:\\MYAPP\\myApp.exe\""
(For Current users)
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"myApp"="\"C:\\MYAPP\\myApp.exe\""
you can do this via programming or just by making a .reg file and then run it. another simple way you can use is to create an icon for your exe file in the windows startup folder.
|
|
|
|
|
shaun77 wrote:
another simple way you can use is to create an icon for your exe file in the windows startup folder.
A shortcut, actually, not an "icon". The Startup folder is also in Start->Programs->Startup, which is also scoped for either the user or the system depending on the platform (Windows vs. Windows NT). The best way would be to create a Windows Installer project and use the Shortcuts designer there. The Windows Installer runtime automatically determines the platform and uses a global shortcut, or it can use a user shortcut (if available) depending on your options.
For examples, on Windows NT-based platforms (NT4, 2000, XP, 2003, and all future versions) except for NT4 (everything was in C:\Winnt\Profiles), you can use either C:\Documents and Settings\All Users\Start Menu\Programs\Startup for all users, or C:\Documents and Settings\username\Start Menu\Programs\Startup for a specific user.
For Windows, this is typically C:\Windows\Start Menu\Programs\Startup.
Of course, replace the C: drive with your system drive, but this is usually C:. Again, if you use a Windows Installer project, it automatically resolves all special shell folders.
To add a Windows Installer project to your solution (which can then take advantage of build targets for your other proejct(s)), right-click on your solution, select "Add->New Project", select "Setup and Deployment Projects", then "Setup Project". Give it a name and click "OK".
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Many thanks! I wish I could buy you guys lunch.
I was soooo close and didn't even realize it. I already had a shortcut installed in the start menu, but following your suggestions I did the following:
In my installer project I openned the File System Editor and under the User's Start Menu folder I added a Programs folder and under that I added a Startup folder and in that I added a shortcut to the active project.
This works on 98, 2000, and XP.
My client will love me even more.
Thanks again,
Joe
|
|
|
|
|
Hello, Sir
How to get the target that *.lnk link to
Thank You.
|
|
|
|
|
Hi,
Im developing a project which consists of a client which sends images to a server. The server must store these images in a database, and I am having a multitude of problems. I first tried creating a web-service which accepted the image as a parameter in a web method, but it would appear that System.Drawing.Image.Bitmap is not serializable - it generates an XML Serialization error. I then thought I would try and access the database directly and just store add images using an INSERT command, but I am getting an error message that the 'object' (I believe this refers to the image object) must implement IConvertable.
Can anyone help me at all - I've been trying to sort this for the last week, and I really need to sort it.
Thanks in advance
Peter
|
|
|
|
|
Adding images to a database has been covered numerous times in the past. Please use the Search Comments link above and search for previous solutions, such as these found in a recent thread: http://www.codeproject.com/script/comments/forums.asp?msg=704229&forumid=1649&XtraIDs=1649&searchkw=database+image&sd=10%2F22%2F2003&ed=1%2F20%2F2004#xx704229xx[^].
As far as sending images (either Image orBitmap , a derivative of Image , neither of which are serializable), most implementations use a MemoryStream (or another Stream like FileStream , especially if the images were already saved to disk) to save the images to a buffer (a byte[] array), which is serializable (since Array is serializable).
Either way, once your image gets deserialized on the server, you still have to insert it into the database. Depending on your implementation requirements, you might actually be better off storing the image on the file system and inserting a file reference (like the URL to access it remotely, which you can always use Page.MapPath to get the file system path) into the database. This way, if you want to display the images in a web page, you don't have to extract them first or use a page to dynamically extract and stream them out using a different content-type than a normal page (ex: .aspx file).
For a good example using SQL Server, see C# Photo Album Viewer[^]. If this is for use on a server, I highly recommend that you do not use Access. Use a real RDBMS that implements ACID properties like SQL Server or the MSDE (a connection-limited version of SQL Server). You can find more information about SQL Server at http://www.microsoft.com/sql/default.asp[^] or download the MSDE for free at http://www.microsoft.com/sql/msde/default.asp[^]. This way, you can take part in transaction processing, stored procedures, triggers, and much more with much greater efficiency than a file-based database like MDB files.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks once again for your help Heath!!
I did use the search facility for the message boards and general articles, but I was unable to find something which actually stored the image in the database, not just a referance. I will consider doing this though in my implementation.
I am using MS SQL Server - not access, and I will carefully go through the mentioned articles.
Thankyou once again - I will battle on!
Peter
|
|
|
|
|
You can convert it to a byte[] before send to the server and then store it directly.
public StorePhoto(byte[] photoContent)
{
.......
SqlParameter param1 = new SqlParameter("@photo",SqlDbType.Image);
param1.Direction = ParameterDirection.Input;
param1.Value = photoContent;
.......
}
|
|
|
|
|
Since I may transfer to C# from Visual C++, is there any memory management in C# like pointers, since I don't like them too much and is there anything new in it... maybe a website would help explain it better if it dealed with these kinds of things...
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|
|
Sure there's a web site...this one! There's also http://msdn.microsoft.com[^], the Microsoft Developer Network, and many, many other sites.
First of all, understand that C# is merely one of many languages that target the Common Language Runtime, the runtime of the .NET Framework (and like all languages, the compiler produces very similar Intermediate Language, or IL, making assemblies available across languages and platforms). Code that runs in the CLR is often called managed code because the CLR manages all memory, so don't use pointers unless you have to! This requires an unsafe context.
In .NET, all objects are already reference Types and inherit from System.Object , except for enums, structs, and intrinsic types like Int32 (int ), Byte (byte ), et. al., which derive from ValueType (which also derives from Object , but is handled different by the CLR). These are allocated on the stack. Some managed languages like C# can use unsafe contexts for things like pointer manipulation, but this is usually only done when processing image pixels. For the most part, don't use it and just let the CLR do its job: managed memory.
The best thing is to start reading the .NET Framework SDK, starting with the Overview[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi all
I wrote a large MFC application and recently began to convert it to .NET framework. I do this step-by-step by rewriting some parts and components written in MFC into C#. Now I have application written in MFC with a lot of C# components talking between them using com-interop.
But now i want to perform some serious testing. I've tried some available products such as Rational Quantify and DevPartner and all of them had problem to handle with my app because it written both in MFC and C#.
What is the best way to test such app (CPU, memory etc.)?
Can anybody recomend me about some other monitoring product?
thanks.
|
|
|
|
|
2 words: Performance counters There are a whole host of them.
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
Hi Every Body,
Just imagine you have two application, one is been written in C# and another is by delphi.
I just wanted to know, if i create a report in the c# and i set everything ( data source,parameter,...) in the use .net emviroment, can the other parties based on delphi open my report and change some property (for example passing parameters) and show it up?
any hint is appreciated.
|
|
|
|
|