|
Rather than using the regex aproach i would suggest Date.TryParse(in "string containing date", out date_object) ... as date varies on localization it might be a lil overhead building a regex to handle all kinds of formatting and might require, depending on case, a lot more processing time.
Code? Yeah i love it fried together with a glass of wine.
|
|
|
|
|
Based on the string you provided...
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace TestConsole
{
class Program
{
static void Main(string[] args)
{
string myString = "hj/dfsks jh/f12/353 @@2df 23/11/2008 kjdl jf\\ioi jr4398 rjeo i";
string[] parts = myString.Split(' ');
DateTime dateFound;
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
DateTimeStyles styles = DateTimeStyles.None;
foreach (string part in parts)
{
DateTime date;
if (DateTime.TryParseExact(part, "dd/MM/yyyy", culture, styles, out date))
{
dateFound = date;
break;
}
}
}
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi ,
I am CommandBar class for creating Addin, in which I want to call function Control.Add(). This function take 4 parameter of type object and all parameters are Optional type. I have to pass only one parameter but it is not allowed to me.
Code is as
Controls.Add(MsoControlType.msoControlPopup);
This function is worked in VB.Net but not in C#.net. So is there any different way to call optional parameter in C#.
Thanks
aaa
|
|
|
|
|
C# doesn't support optional parameters. Either pass null or Missing.Value
Simon
|
|
|
|
|
Hi Simon,
Is there any other way to pass optional parameter in C#.I tried with null and Missing.value but it is not working. CommandBar is .Net framework class and some functions have optional parameter defined, so they use in C#.Net.
Thanks
aaa
|
|
|
|
|
Currently C# does not support optional parameters. It is being considered for inclusion in .net 4.0[^]
It supports overloading, but that's different. If you are calling an overloaded method, then just leave out the other parameters and the appropriate overload will be called automatically.
I've never come across a CommandBar class in the .net framework. There's one in the office object model, but that's not written in .net.
Post some of your code so I can see what you are doing.
Simon
|
|
|
|
|
|
Your answer was unacceptable!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Dammit. Rejected again. When am I going to learn to give the answer the poster wants, and not the correct one.
[Thanks for the booster vote ]
Simon
|
|
|
|
|
Wait for .Net Framework 4.0
it is supported
WaelA
Senior Software Engineer
abu_wer@hotmail.com
|
|
|
|
|
Hi,
I use a DateTimePicker in my project.
In the valuechange event I wrote some code.
The problem is that when I click on < (previous month) or > (next month) buttons or change the year, this event will fire. I want this event only when the date is click not in change month or year.
How its possible, please help me.
thanks in advance.
Justin
vchvchbv
|
|
|
|
|
You can use CloseUp event. It is fired when drop-down calendar is closed.
--
"My software never has bugs. It just develops random features."
|
|
|
|
|
Thank you
Justin Jose
|
|
|
|
|
hi
i have three page, in my page1 has search option if i did search then results shown in gridview in the page1. the grid has edit button, if i click the edit button, then the page2 is displayed all the relevent data with a update button. if i click the update button then the page3 is shown, in that page has link button to page2. again i came from page3 to page 2 and go to page3. and came to page2 now i want to go page1 without any loss in the page1 gridview.
please give ur idea.
thanks
with regards
b.balachandhar
modified on Friday, November 14, 2008 1:53 AM
|
|
|
|
|
You're looking for the ASP.NET forum.
|
|
|
|
|
Hi all,
I am working Windows application. I have a requirement of downloading the files from a website.
When the application is runnning (downloading files), if user shutdown the
the system i need to cancel that shutdown and i have to display message like "Downloading files is not completed.You want stop Downloading files, if yes Click on btn_ShutDown ,if not btn_CancelShutDown.
For that i used Form1_Closing Event.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason.Equals(CloseReason.WindowsShutDown))
{
// I dont know the actual logic, but i tried the below one. But its not working
e.Cancel; // But its not working.
}
}
Please suggest me how to cancel the Shutdowning of system.
Thanks in advance.
|
|
|
|
|
|
Thanks for your replay.
I already tried the logic present in the link
http://www.dotnetspider.com/resources/4541-Cancel-shutdown-e-computer.aspx[^]
But it's not worked.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason.Equals(CloseReason.WindowsShutDown))
{
Microsoft.VisualBasic.Interaction.Shell("shutdown -a", AppWinStyle.MinimizedFocus, false, -1);
MessageBox.Show("Shutdown process cancelled!");
}
}
|
|
|
|
|
It doesnt' work because you cannot start new .EXE's while a shutdown is in progress and -a only aborts a PENDING shutdown, one which hasn't happened yet, so you're code is getting notified too late.
This[^] is how you really should do it. But, you really shouldn't be doing this at all.
|
|
|
|
|
I dont know how to get the status of windows, if its shutting down, but u can use, i think, this code on if the user doesnt want to shutdown.
add this:
using System.Diagnostics;
// code for canceling the shutdown
Process.Start("shutdown -a");
// code for shutting down
Process.Start("shutdown -s");
//The process command is just like Start/Run
I hope somebody helps you with "if shutting down"
Regards,
Matjaž
Força Barça!
|
|
|
|
|
call "shutdown -a" after fetching the reason either using the System.Process namespace either using Microsoft.VisualBasic.Interaction.Shell to cancel the windows shutdown. Also if the user hits shutdown choosing to abort file download, run with one of the options specified above the following shell command: "shutdown -s" for shutdown or "shutdown -r" for restart or "shutdown -t [time_in_seconds] -[r or s] for a "timed" restart or shutdown.
Code? Yeah i love it fried together with a glass of wine.
|
|
|
|
|
Exactly. For more information on the shutdown function, you can go Start/Run and open "cmd" and then type "shutdown /?".
Força Barça!
|
|
|
|
|
Hi..all
I want to create an software using C# (Visual Studio 2005)
My app is expected to monitor the copy-paste file process that is doing by the current logged user.
I only want to get 2 main informations:
1. The address of the source file
2. The address of the destination file
For example, if the user copy file textX.txt from folder C:\Document to folder E:\Data , my application should catch : The source address as C:\Document\textX.txt and The destination address as E:\Data\textX.txt
I already used FileSystemWatcher, but it can catch the destionation address only. How can I get the source address as well?
Any solution would get my great appreciation.
Thanks..
|
|
|
|
|
You can't use the FileSystemWatcher to do this. There's no event you can use either. This is something that you have to do by intercepting the calls bouncing around the Shell and/or I/O subsystem. Don't ask me how to do it, it have no idea. But that's the only place you can do this.
|
|
|
|
|
Dave Kreskowiak wrote: something that you have to do by intercepting the calls bouncing around the Shell and/or I/O subsystem.
Oh boy, that sounds like a load of fun
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|