|
You can get the count from the list itself.You can store it some session variable (if user specific) or application varaiable(if application specific) for any other use.
One thing How are you getting the count of the table.Is it coming at runtime?Can you be more specific to requirement?
Cheers!!
Brij
|
|
|
|
|
A windows service is supposed to launch an application, passing some arguments to the executable. I am trying to do this using CreateProcessWithLogonW(string principal,
string authority,
string password,
LogonFlags logonFlags,
string appName,
string cmdLine,
CreationFlags creationFlags,
IntPtr environmentBlock,
string currentDirectory,
ref StartupInfo startupInfo,
out ProcessInfo processInfo) API function.
I set the parameter "cmdLine" for passing string to the executable. The following code doesn't get me anything ...
static void Main(string[] args)
{
// that doesn't give any value
string acrossprocessvalue = args[0];
//neither the following lines
string test = Process.GetCurrentProcess().StartInfo.Arguments;
}
any help ...
fulbright
|
|
|
|
|
Process.Start will do it. Process class provides options to supply arguments too.
|
|
|
|
|
Thanks for the answer ... I started with Process.Start() actually but that wasn't fulfilling the requirements. e.g, The windows service is running under the "Network Service" user, a less privileged user,that wont be having the rights to display application on desktop, etc. So for such security tunnings I had to use CreateProcessWithLogonW() API function.
Madni
|
|
|
|
|
"cmdLine" argument that i'm trying to pass to CreateProcessWithLogonW() is a string basically but does it have some specific format ? I'm simple passing the value as
cmdLine = "testargument";
Is it OK ????
fulbright
|
|
|
|
|
Pass whatever you want, as long as the spawned app understands it.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All ,
I downloded a sample project from internet it is using the following line .
public class BusinessCollectionBase<T> : ValidationCollectionBase<T> where T : ValidationBase
{
...........
some code here
...........
}
public abstract class ValidationBase
{
...........
some code here
...........
}
public abstract class ValidationCollectionBase<T> : Collection<T> where T : ValidationBase
{
...........
}
please anyone explain above line code (specially why we used <T> with where keyword) .
-------------------------
SANTOSH GAUTAM
-------------------------
|
|
|
|
|
T is the type and where is a constraint which will ensure T will be a type of ValidationBase . Read about generics[^]
|
|
|
|
|
hello froum
I am writing the elements to xml file on runtime,and also using them. It is working properly.
XmlDocument xmlDoc = new XmlDocument();
string path = AppDomain.CurrentDomain.BaseDirectory + @"\XMLFind.xml";
xmlDoc.Load(path);
XmlNodeList xmlNS = xmlDoc.GetElementsByTagName("testword");
The xml file is in the bin folder.
but the problem is after creating setup the xml file is visible to every body so it can be deleted accidently.
If the xml file is placed in the project then while using the output (after creating its setup) it gives the runtime error
Could not find the C:\Program Files\hts\SetupFinal\XMLFind.xml.
can anybody help me...
Regards
Rahul Adya
|
|
|
|
|
rahuladya wrote: but the problem is after creating setup the xml file is visible to every body so it can be deleted accidently.
There is no way to secure it. Just check the file existence before you read it and tell user if it is not available.
|
|
|
|
|
hello navneeth
Yes i know but the issue is not here, we can secure it by adding it to solution explorer and after creating setup it will not be visible to anybody.
The problem is how to find the xml file present in the project on runtime because the directory path will be changed after deployment.
Rahul adya
|
|
|
|
|
rahuladya wrote: because the directory path will be changed after deployment.
Place it in the application directory. Application.ExecutablePath will give you the current directory where application's exe resides.
|
|
|
|
|
hello froum
I am writing the elements to xml file on runtime,and also using them. It is working properly.
XmlDocument xmlDoc = new XmlDocument();
string path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.LastIndexOf("bin\\")) + @"\XMLFind.xml";
xmlDoc.Load(path);
XmlNodeList xmlNS = xmlDoc.GetElementsByTagName("testword");
The xml file is in the bin folder.
but the problem is after creating setup the xml file is seen to every body so it can be deleted accidently.
If the xml file is placed in the project then it gives the runtime error
Could not fine the C:\Program Files\hts\SetupFinal\XMLFind.xml.
can anybody help me...
Regards
Rahul Adya
|
|
|
|
|
hello all
How to allow textbox to enter only alphabets using RegularExpression (Regex)
i have added the namespace
using System.Text.RegularExpressions;
Thanks
|
|
|
|
|
regex that allow only alphabets is below
^[a-zA-Z\S]+$.
You can validate the entered text in textbox by this.
Cheers!!
Brij
|
|
|
|
|
hello Brij
can u just show the code in 2 to 3 lines .....
|
|
|
|
|
|
Try handling the KeyDown event for the TextBox . If the character is one you don't want (a digit or punctuation for example), swallow it by setting e.Handled to true . That should work.
|
|
|
|
|
There's a bit more to this than you may think as you'll need to allow navigation and edit key combinations in your text box so just dropping the characters you don't want isn't enough. Also, you'll need to handle pasting of information to make sure it's valid.
I wrote an article[^] that does something similar - only numbers - but it can easily be adapted. It doesn't handle text that may be placed programatically, but a little checking in OnTextChanged would handle that.
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)
|
|
|
|
|
what is the C# equivalent of "atoi" in Visual C++?
thanks
|
|
|
|
|
PAsk the questions in Right forum.Put in C++ forum.
Cheers!!
Brij
|
|
|
|
|
int.Parse or Convert.ToInt32 . They will throw an exception if the string cannot be converted. int.TryParse won't throw an exception, and should be used if the string possible could not be valid.
|
|
|
|
|
But what if you have a string like "us dollars $34cheap". TryParse gives 0 for the result.
atoi would give 34.
Is there anything in C# that does exactly what atoi does in C++?
|
|
|
|
|
I don't know of anyting, but it wouldn't be hard to implement it yourself.
Just walk all the characters in the string, and copy the ones that are numbers to a temporal string, ignoring letters and symbols. Then int.TryParse that temporal string and you're done.
|
|
|
|
|
Hi,
I am using the App.Config file to store few mail settings including the static text that will be used to send the mail. All the key/value pair is working fine except for the static content pair where in I am not able to use HTML formatters to format the mail message. I am using the following statement:
--------------------------------------------------------------------------
<add key="MailStaticContent" value="Hi,<br><br>Please find attached your daily report.<br><br>Thanks,<br>Reporting System<br><br>Note: Do not reply to this auto-generated message. To send mail to the Coordinator, please use the application's 'Send Mail' link.";
--------------------------------------------------------------------------
I get the following message:
Application Configuration file "App.config" is invalid. hexadecimal value 0x3C, is an invalid attribute character. Line 21, position 44. <app_path>\App.config 21 44 <app_name>;
It is a mandate as per the design to use a HTML based mail and the values should be managed through the App.Config.
Any suggestions on how to rectify this issue?
|
|
|
|