|
azusakt wrote:
So, any build-in method can do that??
try
{
}catch(Exception)
{
throw new UserException("user iq dropped below required standard");
}
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi, thanks for your reply.
I just found that the Path.InvalidCharacters contains 15 characters, but there are only 4 characters is invalid.
I want to check if the entered path contains these characters :
\ / : * ? " < > |
Is it the only way is to check by myself??
|
|
|
|
|
Hi
I'm trying to programmatically execute an interactive CLI program, that is one that not only spits out text to stdout, but also requires input from stdin from time to time. The program I'm trying to launch is the Cisco VPN client, but since I've not gotten anywhere with it and I can't post the client here for license reasons (plus it wouldn't help anyway) I've written a small interactive cli program that I'm using as a test vehicle. Here it is:
static void Main(string[] args)
{
Console.Write("Login[]");
Console.ReadLine();
Console.Write("\r\nPassword[]:");
Console.ReadLine();
Console.Write("\r\nDo you wish to continue? y/n");
string answer = Console.ReadLine();
if (answer.Equals("y"))
Console.WriteLine("yippie");
else
Console.WriteLine("aborting");
}
And I'm launching this test program as follows:
static void main(string[] args)
{
ProcessStartInfo psi = new ProcessStartInfo("c:\\temp\\inputreader.exe");
psi.RedirectStandardOutput=true;
psi.RedirectStandardInput=true;
psi.UseShellExecute=false;
psi.CreateNoWindow=true;
Process proc = Process.Start(psi);
StreamReader reader = proc.StandardOutput;
string line = "";
while ((line = reader.ReadLine())!=null)
{
if (line.Equals("Login[]"))
{
proc.StandardInput.WriteLine("login");
}
if (line.Equals("Password[]:"))
{
proc.StandardInput.WriteLine("password");
}
if (line.Equals("Do you wish to continue? y/n"))
{
proc.StandardInput.WriteLine("y");
}
}
}
Now, if my test vehicle did not require any input from stdin, the above could would work. However, as it waits for some input from stdin, the while ((line = reader.ReadLine())!=null) line sends the controlling program in an infinite waiting loop. If I don't redirect stdout and don't set createNoWindow to true, I can see that my test vehicle is waiting for input that never comes.
Does anybody know what I have to change to make this work?
Regards
Stephan
|
|
|
|
|
i am currently learning c#.net and am able to add items in a listbox via a control button. however, i have not been able to delete a specific listbox item using another control button (i.e. delete). can anyone give me a suggestion? thanks.
Sincerely,
Jason C. Ranin
Software Quality Assurance
|
|
|
|
|
In a Listbox , all items are stored in a 'collection'. You can access this collection using myListbox.Items . Use an indexer (e.g. a number which specifies which items you want) to select a specific item to manipulate. For example, myListBox.Items[0] returns the first item, myListBox.Items[1] the second, and myListBox.Items[myListBox.Items.Count - 1] the last item.
You can use the myListBox.Items.Remove() and myListBox.Items.RemoveAt() methods to remove an item. Look in the documentation of the ListBox for further info.
- Daniël Pelsmaeker
As I said before: I never repeat myself!
|
|
|
|
|
This is an example where a listbox item is selected:
private void btnDelSelectedItem_Click(object sender, System.EventArgs e)
{
if(this.TheListBox.SelectedItem != null)
{
for(int i = 0; i < this.TheListBox.Items.Count; i++)
{
if(TheListBox.SelectedItem.Equals(TheListBox.Items[i]))
{
TheListBox.Items.RemoveAt(i);
i = TheListBox.Items.Count;
}
}
}
}
This is probably not the simplest way to do it, but it works.
I've used this in my code, because I needed to check what kinde of item it was that should be delited, and then make "somrthing happen" depending on the item and the items serounding it.
Hope it helps
Thomas
|
|
|
|
|
Thanks a million. however, there is one problem that i forgot to ask in conjunction with this previous issue. i have actually written each listbox items in a text file. the other part to deleting them from the listbox is to delete them from the text file also. would u happen to know how to approach this since I can't seem to fing the right way. thanks.
Sincerely,
Jason C. Ranin
Software Quality Assurance
|
|
|
|
|
It depends how you save the data, if it is a XML document, I've heard that there is som methods that alow you to modefie singel lines in the file.
The easy way, if there aren't to many items in the List, is to resave all the file.
Hope it helps
Thomas
|
|
|
|
|
Well, it would be quite easy to remove the item using listBox1.Items.Remove(listBox1.SelectedItem) or something similar I believe. And after you have done that, why not just call a method that will rewrite your text file with the current listbox items..That would be the simplest approach in my opinion.
|
|
|
|
|
I have a web page which stores some gif images. I want to be able to read those images from my web application and display them in a picturebox. So far, I'm not making any headway with the Image class. (Apparently the FromFile Method doesn't accepts URI) . Does anyone know which BCL class to use to get those images?
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
hi,
you can try this out...
System.IO.Stream uriStream = System.Net.HttpWebRequest.Create(new Uri("[The request URI]")).GetRequestStream();
Bitmap bmp = Bitmap.FromStream(uriStream);
PictureBox pbDemo = new PictureBox();
pbDemo.Image = bmp;
Hope this works... actually I couldn't run this but it should work... sorry for not giving full proven code...
regards,
Aryadip
Cheers !! and have a Funky day !!
|
|
|
|
|
That's allright... I just neede the pointer. Thanks again.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
Actually, use Page.MapPath or Server.MapPath (Server is an instance of HttpServerUtility provided on several objects in ASP.NET). This maps the virtual path to a physical path that you can use with Image.FromFile .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Cool. Thanks for the tip.
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
Actually, I misunderstood your post so ignore what I said. That method is handy when you need to get the physical path of a file based on its virtual path in ASP.NET. My bad.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Help me!
How can create series number in setup InstallShield ?.
Thank !
|
|
|
|
|
As I told you the first time - this question has nothing to do with C# and doesn't belong in this forum. For one, creating a serial number for your installer is completely up to your implementation. If you want help, you should go to http://www.installshield.com[^] and look for answers or help (like a newsgroup) there.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I made this program that has a notify icon, and when you exit the program, i have it just minimize the program to the notify icon instead of actually shutting the program down. The only problem is that when you try to shut off your computer, and the program is still running, your computer doesn't shut down. Any suggestions?
By BigBlob202
Dinco Inc.
|
|
|
|
|
use ExitWindowsEx APi to shut down
Sreejith S S Nair
|
|
|
|
|
That's to shutdown the application - not allow the application to shutdown properly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In the event that your using to capture the Close button, I assuming it's OnClosing, you could check to see what the current state of your app is. If it is already minimized, then you can set the e.Cancel=False and let your app quit. Then the problem becomes how do you handle the situation where your form is in an un-minimized state.
You might want to look into handling the Application.Exit event to see when that fires. You OnClosing event might be able to be used for minimizing and the Application.Exit event might be able to be used for an actual Exit and set a flag that OnCloing uses to know that an actual application shutdown is happening and not minimize and cancel it.
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Override WndProc in your main application Form (the Form you pass to Application.Run and handle the WM_ENDSESSION (0x0016) message, something like:
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0x0016) Application.Exit();
} You could also implement IMessageFilter and add a reference to your implementation using Application.AddMessageFilter .
Changes are that you've overridden OnClosing or handled the Closing event of your Form in order to "minimize" your application to the systray, right? If you set the CancelEventArgs.Cancel property to true and hide your Form , this is probably why it's not shutting down - you're preventing the WM_CLOSE method to be sent to the main application Form . Handling the Windows message WM_ENDSESSION should fix this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey all
I have 2 tables on my C# window form, say: interests table is parented to persons table. How could I show all interests from interests table in a checked box list? In addition to that, I would also like to be able to show some checked boxes that show these particular checked boxes are the interests of a particular person, and will be able to change it's data by checking and uncheking the check-boxes listed.
Thanks a lot.
|
|
|
|
|
You should try reading the documentation. Most of what you need - especially binding the checked state to a boolean column - is discussed in the .NET Framework SDK.
As far as having a parent-child relation view, you need to do this manually. When an item is checked in the parent ("Persons") view (the Control - whatever it is - bound to the "Persons" table), then you either need to call DataTable.Select on the "Interests" table or filter the DataTable by either getting a DataView from DataTable.DefaultView or creating a new DataView over the table by instantiating a new DataView , passing the "Interests" table as an argument to the constructor. You can then use the DataView.RowFilter property to filter the rows. Bind the DataView - not the DataTable - the CheckedListBox control.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok.. I dun really get ur explanation. I didn't use databind function to show all
interests from the interest table in the CheckedListBox, instead I used array, selecting all interests and put the into row. In this case, my first problem is to solve how do I pre-select the check boxes dependeing on the interests value of a person from the table...
|
|
|
|