|
I found this code, that should validate an Email address according to the RFC2822.
Now im not the big regex user so i would like it if someone could verify this for me.
^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$
Thanks..
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
You might want to read this[^] page on validating email addresses. It's very enlightening, and should go a long way to answering your question (pay attention to items such as international email addresses).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks Pete, will do...
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
Good evening,
I am trying to work out if it is possible to work out which DLL the RunDLL32.exe process is "running" through C# (or C++)
Any help/guidance would be sincerely appreciated
|
|
|
|
|
|
The Modules list doesn't actually contain the dll that's loaded by rundll32. You need to do extra work to get that information.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You can do this with WMI. Here's a sample combining the Process and ManagementObject classes to show some useful info:
string process = "SELECT CommandLine FROM Win32_Process WHERE ProcessID = {0}";
foreach (Process p in Process.GetProcessesByName("rundll32"))
{
using (ManagementObjectSearcher mos = new ManagementObjectSearcher(string.Format(process, p.Id)))
{
foreach (ManagementObject mo in mos.Get())
{
string[] commandLine = mo["CommandLine"].ToString().Split(',');
Console.WriteLine(string.Format("{0} was started at {1}.",
commandLine[0].Substring(commandLine[0].IndexOf(" ") + 1), p.StartTime));
}
}
} There's a whole hunk of substringing going on with the command line to get the DLL because the command line would be Rundll32.exe c:\PathToMyDll\MyDll.dll,Entrypoint so we need to parse it out.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks very much, this works and works well!
|
|
|
|
|
|
Kindly check the below program.
using System;
namespsace TestException3
{
Class program
{
static void Main(string args[])
{
try
{
string s1,s2,ans;
char type,type1;
Console.WriteLine("please enter the variables : ");
s1=Console.ReadLine();
s2=Console.ReadLine();
type=Convert.ToChar(s1);
type1=Convert.ToChar(s2);
if(!(char.IsDigit(type)) || !(char.IsDigit(type1)))
{
throw new Exception("Please Enter numbers only");
}
else
{
ans=Convert.ToString(Convert.ToInt32(s1)+Convert.ToInt32(s2));
Console.WriteLine(Answer : {0}",ans);
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine("Message : {0}", e.Message);
Console.ReadLine();
}
}
}
}
|
|
|
|
|
Hint:
string number = "1234567890";
foreach (char c in number)
{
Console.WriteLine(c);
}
Another Hint:
int iNum = 0;
string strNum = "1234567890";
if (int.TryParse(strNum, out iNum))
{
Console.WriteLine(iNum);
}
|
|
|
|
|
You could try the following.
ConsoleKeyInfo ck = Console.ReadKey();
char Key = ck.KeyChar;
|
|
|
|
|
Try this:
public void test()
{
try
{
Console.WriteLine("Please enter the variables : ");
Int32 valueOne = ConvertLine(Console.ReadLine());
Int32 valueTwo = ConvertLine(Console.ReadLine());
Console.WriteLine("Answer : {0}", valueOne + valueTwo);
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("Message : {0}", e.Message); Console.ReadLine();
}
}
private int ConvertLine(string value)
{
try
{
if (String.IsNullOrEmpty(value) == false)
{
return Convert.ToInt32(value);
}
Console.Error.WriteLine("Empty field is not supported : default value used 0");
}
catch (Exception exception)
{
Console.Error.WriteLine(String.Format("{0} : default value used 0", exception.Message));
}
return 0;
}
|
|
|
|
|
I have a problem with a webbrowser control not displaying an image from the local harddrive of the Windows Mobile 5 PocketPC I have.
Basically I am writing the HTML code to the browser:
webBrowser.DocumentText = @"
<html>
<body style='text-align: center; margin-left: auto; margin-right: auto'>
<img src='" + AppPath + @"\loading.gif' />
</body>
</html>";
The AppPath is:
private string AppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
Now I had it throw a message box before that and it gives: "\Program Files\Mobile Inventory" which if you add \loading.gif on that it would be correct. I have even verified that the loading.gif image file was in that location and it was.
It still just shows a red X. If you are wondering why I am doing it this way instead of a picture box it is because a picturebox on win mobiile cannot display animation. (Nice huh)
|
|
|
|
|
This may not be the answer, but I had similar problems with ASP.NET, and resolved it when I realized all paths are relative to the page current directory.
You can try replacing the AppPath with "~" for a web-centric root, or
Use "<%= Page.ResolveUrl("~")%>" in the path, and it all resolves in ASP.NET:
Resources/Images/Logos/myLogo.gif" />
(and yes, I know the double quotes don't look right - works though.)
Gotta be worth a try.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I didnt have any luck with that.
<img src="<%= Page.ResolveUrl("~")%>Resources/Images/Logos/myLogo.gif" />
doesn't work because of the quotes. Using the quotes ends the string line. I did try:
<img src='<%= Page.ResolveUrl('~')%>Resources/Images/Logos/myLogo.gif' />
But was unable to get that to work. I also tried just this:
<%= Page.ResolveUrl('~')%> to see if it would just print the URL it resolved and it prints nothing.
I also tried this:
<img src='/Program Files/Mobile Inventory/loading.gif' />
Which is the exact path and it still won't work! I also tried:
<img src='loading.gif' />
LOL.. so frustrating! It shoul be easy! This is a Windows Mobile version 5 (not 6) barcode scanner
|
|
|
|
|
As Griff said, plus you may have a problem with the (back)slashes: don't mix backslashes and forward slashes, and I tend to have more luck with forward slashes in HTML.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Copying an example I found, I have a Windows application with no main form that just manages a NotifyIcon in the tray with its small context menu functions. As such, its Main has Application.Run() instead of Application.Run(someform) . That part works fine.
Now I need it to conditionally show/hide a form. There are no user interaction controls on the form (it's display only) and the "default" condition is to have the form hidden. If I use Form.ShowDialog() , the form appears, but blocks the user interaction that is associated with the NotifyIcon.ContextMenu and I have no way to remove it. If I use Form.Show() to keep the user interaction with NotifyIcon functional, the form appears but none of its contained controls render and it forever shows the Wait cursor.
After much fruitless searching for a threading issue (even though InvokeRequired is always false), I came across a clue that it might instead be a message pump issue. This makes some sense (since I can fully show and hide the form if I do it within the ContextMenu event handlers), but I can't find enough info to compose a candidate solution.
How do I get this form to complete its rendering without making it modal?
|
|
|
|
|
I found something that works, but I'd like to know if this was really the preferred solution since it seems a bit awkward to me. However, this solution does support the message pump hypothesis I mentioned in my question.
In the constructor for the form that I want to display, I start up an auto-reset Timer that fires every 200 (for now) ms. In the timer event handler, I call Application.DoEvents() . That's all it took... a surrogate message pump!
Additionally, the Show, Hide, Close, and content update actions all had to be wrapped with Invoke boilerplate, but that makes sense.
Wildly simple, but was there a better way? If I had two forms to show, would each require its own timer solution?
|
|
|
|
|
|
|
When he did that yesterday, it got his article a good crop of 1 votes. So he does it again today.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Another lame attempt at self-promotion
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Your article sucks. Is that what are waiting to read? Don't you understand replies to your previous post?
I haven't even seen the article nor voted it.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Dude, you really got some nerve to start all that
|
|
|
|