|
We used to have that hardcoded before, but now the User is enabled to enter a RegExp themselves for customization.
Where I previously had the Length, allowed chars and such, I now have the RegExp and need to get at least the Length (validation for allowed chars is now done with the RegExp right away).
I want to keep it simple for the user, so just enter a RegExp and dont think of the rest; I dont want them having to enter a RegExp, in addition to that the Length of the RegExp field (User-thoughts: "Why do I have to enter that twice?"), Conditionals whether it allows only Lower/Upper Case chars or both (User-thoughts: "The RegExp tells you anyways, only capiutal letters?").
User Expierience is an important part of Software design; getting the user to enter 3 or more "redundant" informations is rather annoying.
On the other hand, providing an Editor that lets them piece together Conditions like we had them before (CapitalLetters(starting at 0, length 1), Numbers(1, 2), Dot(3, 1), Numbers(4, 2) for "[A-Z][0-9]{2}\.[0-9]{2}") would probably confuse the user aswell (think of how complex the WinForm would be to allow that, when the user is required to enter 6-12 of those expressions in total).
Thanks for your reply tho.
Greetings, BhaaL
|
|
|
|
|
Hi,
I Think this is odd requirement and that's why you need to Parse the regular Expression. This is the best way.
Best Regards,
Chetan Patel
|
|
|
|
|
My code below gets files from a list box and Zip those files into one Zip file.
My propble is: This works perfectly when i log on to the server and do this operation on the sever itself.(it is an Intranet).
But when i do this on my local machine which is on the same network as the server, it only creates the Zip file but its empty.
Can someone please help.
//Zip
txtsave.Text = "c:\\TempUpload";
System.IO.Directory.CreateDirectory(txtsave.Text);
if(ListBox1.Items.Count < 1)
{
listerror.Text = "Please add Files to the list Box and Press Confirm";
return;
}
if (txtsave.Text == string.Empty)
{
listerror.Text = "save folder not selected";
return;
}
string[] sTemp = txtsave.Text.Split('\\');
string sZipFileName = sTemp[sTemp.Length - 1].ToString();
FileInfo fi = new FileInfo(txtsave.Text + "\\" + sZipFileName + ".zip");
if(!System.IO.Directory.Exists(txtsave.Text + "\\TempZipFile\\"))
{
System.IO.Directory.CreateDirectory(txtsave.Text + "\\TempZipFile\\" + ".zip");
}
string sTargetFolderPath = (txtsave.Text + "\\TempZipFile\\");
for (int i =0; i< ListBox1.Items.Count;i++)
{
string filepath = ListBox1.Items[i].ToString();
FileInfo fi2 = new FileInfo(filepath);
if(fi2.Exists)
{
try
{
fi2.CopyTo(sTargetFolderPath + fi2.Name, true);
}
catch
{
System.IO.Directory.Delete(sTargetFolderPath);
listerror.Text = "Error on Files";
return;
}
}
}
try
{
string[] filenames = Directory.GetFiles(sTargetFolderPath);
using (ZipOutputStream s = new ZipOutputStream(File.Create(txtsave.Text + "\\" + sZipFileName + ".zip")))
{
s.SetLevel(9);
byte[] buffer = new byte[4096];
foreach (string file in filenames)
{
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(file))
{
int sourceByte;
do
{
sourceByte = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceByte);
} while(sourceByte > 0); }
}
s.Finish();
s.Close();
}
System.IO.Directory.Delete(txtsave.Text + "\\TempZipFile\\", true);
}
catch(Exception ex)
{
listerror.Text = ex.Message.ToString();
}
|
|
|
|
|
Are you connecting to the server from your local machine ? Is this in ASP.NET ? Seems to me like you wrote code expecting it to run locally, but it runs on the server.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
I am doing a program with c# and mysql database.
the task is actually taking 2 dates out from the mysql database and compare the 2 dates. if it is more than x days den the file will be deleted.
the following is the program that i have done but i am stuck at the logic that is compare the 2 days if more than x days delete the file.
after that i'll run in the schedule task so that it will run automatically at certain time.
here is my code.
string ConnectionString = "server=localhost;user id=name;password;persist security info=True;database=name of database;";<br />
using (MySqlConnection conn = new MySqlConnection(ConnectionString))<br />
{<br />
MySqlCommand cmd = new MySqlCommand();<br />
conn.Open();<br />
if (conn.State == ConnectionState.Open)<br />
{<br />
<br />
<br />
cmd.Connection = conn;<br />
cmd.CommandText = "select history ,lastclrhistorydate from table;";<br />
cmd.CommandType = CommandType.Text;<br />
MySqlDataReader reader;<br />
reader = cmd.ExecuteReader();<br />
if ((reader != null))<br />
{<br />
DataTable dt = new DataTable();<br />
dt.Load(reader);<br />
<br />
if (dt.Rows.Count == 1)<br />
{<br />
int history = int.Parse(dt.Columns[0].ToString());<br />
<br />
string lastclrhistory =dt.Columns[1].ToString();<br />
DateTime currentdate = DateTime.Now;<br />
<br />
<br />
if ((currentdate - lastclrhistory) == history)<br />
{<br />
}<br />
|
|
|
|
|
You can't compare two objects of differnt types. You need to grab the date, as a date, or use DateTime.TryParse to convert it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
but in the database it is already in date
|
|
|
|
|
That doesn't matter because you've now converted it to a String, just because the string contains a DT format doesn't mean it will be interpreted that way, you must tell it that its a DateTime.
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
Did you come from VB, or do you just not know much about programming yet ? you should buy a book on C# and work through it, you're obviously missing some key concepts.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi,
I am doing a program with c# and mysql database.
the task is actually taking 2 dates out from the mysql database and compare the 2 dates. if it is more than x days den the file will be deleted.
the following is the program that i have done but i am stuck at the logic that is compare the 2 days if more than x days delete the file.
after that i'll run in the schedule task so that it will run automatically at certain time.
here is my code.
string ConnectionString = "server=localhost;user id=name;password;persist security info=True;database=name of database;";
using (MySqlConnection conn = new MySqlConnection(ConnectionString))
{
MySqlCommand cmd = new MySqlCommand();
conn.Open();
if (conn.State == ConnectionState.Open)
{
cmd.Connection = conn;
cmd.CommandText = "select history ,lastclrhistorydate from table;";
cmd.CommandType = CommandType.Text;
MySqlDataReader reader;
reader = cmd.ExecuteReader();
if ((reader != null))
{
DataTable dt = new DataTable();
dt.Load(reader);
if (dt.Rows.Count == 1)
{
int history = int.Parse(dt.Columns[0].ToString());
string lastclrhistory =dt.Columns[1].ToString();
DateTime currentdate = DateTime.Now;
if ((currentdate - lastclrhistory) == history)
{
//(File.delete(file)
}
|
|
|
|
|
Hi,
in my Folder of the app there are
tow folder in the bin Folders :
Debug and Release
tha strange thing is that :
under the Solution properties it is set to :
Configuration : Active(Release)
and the OutPut Path is bin\Release\
BUT it always complie it to the Bedug Folder
What am i'm doing wrong?
THANKS
Have Fun
Never forget it
|
|
|
|
|
Have you checked the output path settings in the project's properties (build tab)?
Standards are great! Everybody should have one!
|
|
|
|
|
yes as i wrote "OutPut Path is bin\Release\"
THANK
Have Fun
Never forget it
|
|
|
|
|
Check the project properties and ensure that the output of the project is going to the correct folder for the correct build type.
|
|
|
|
|
yes as i wrote "OutPut Path is bin\Release\"
THANK
Have Fun
Never forget it
|
|
|
|
|
Right click on your solution.
Select properties.
Go to Configuration Properties -> Configuration.
Check what the Project Contents Grid shows.
|
|
|
|
|
i am using this code
MySqlConnection n = new MySqlConnection();
Type type= n.GetType();
System.Reflection.MethodInfo method = type.GetMethod("Add_Clone_Template");
which has four string parameters
Now i dont have the parameters as four strings i have a string
"fun1(fun2()),func4(),func3(fun4(),func1("value")";
fun1,fun2,fun3,fun4 all return a string
how can i pass this
modified on Thursday, March 13, 2008 4:05 AM
|
|
|
|
|
Waheed Ur Rehman wrote: Now i dont have the parameters as four strings i have a string
"fun1(fun2()),func4(),func3(fun4(),func1("value")";
fun1,fun2,fun3,fun4 all return a string
So where are these functions supposed to run on?
|
|
|
|
|
When a mode dialog show in Vista, surrounding screen of dialog is become dim.
How to do this effect with C#?
My OS is XP-sp2 and Vista an among thoseses.
has anybody did this effect sample here?
I want to study.Thanks.
|
|
|
|
|
Your best bet is to do a full screen borderless dialog, and make it semi transparent. Then put your form above it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Why did you vote Christian's answer down? He's told you exactly how to do it.
|
|
|
|
|
i want to change the regional settings -> inputlocale programtically, how can i do that one using c#?
hemanth
|
|
|
|
|
You can use CultureInfo for changing Regional Setting.
Thanks
Anubhava Dimri
anubhava.prodata@gmail.com
9250168195
|
|
|
|
|
but i want to change it on o/s level, not for the particular application or for the form...
thanks for u r reply.
hemanth
modified on Thursday, March 13, 2008 2:47 AM
|
|
|
|
|
U can change Runtime System Information by System Culture Informatin /Shell Command
using Shell32;
Shell objshell = new Shell();
objshell.ControlPanelItem("intl.cpl");
ANUBHAVA Dimri
anubhava.prodata@gmail.com
925168195
|
|
|
|