|
TryParse, types like bool, int and double expose a TryParse method which returns false if they fail
string s ="NotABool";
bool b;
if (!bool.TryParse(s, out b))
{
// not a bool.
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks, I'll try this in the morning.
Leo
Leo T. Smith
|
|
|
|
|
I want to write an app that piggie backs off of the Windows VPN connection. I can make it launch the connection and conect. But I am unable to restore the connection from the Windows status bar, i.e. System Tray i.e. Notification Icon Area.
Anyone have any ideas???
Thanks!
RABB17
"Nothing fancy needed, please just solve all our problems as quickly as possible."
|
|
|
|
|
I have a problem that should be simple to solve except I cant seem to find the answer anywhere.
I would like to be able to set the "Windows UserName and Windows Password" and then use Directory.Exists() inside a Windows Service (using Visual Studio 2005 .Net 2.0) to check to see if a particular directory exists. There can be a directory where UserName=Admin and Password=ABC needs to login first to see if that directory exists. There can be another directory that the user "Admin" CANT see but user "Tester" can. In that case UserName=Tester and Password=DEF needs to log in and then use the Directory.Exists().
I dont want to have to set the userid and password in the installer because only "I" the programmer can set that.....another words....I have to set the username and password BEFORE an installation package is created. That is why it will not work. I need different users to provide there windows login and password.
Any help would be great.
Chris
|
|
|
|
|
Have some commandline or preferably a small Cassini Websever to be served from EXE on a defined port. Authenticate the user and you can create username/passwords, which you can securely store. The master username and password can be one-time only and should be disposed off once the admin has started creating his account.
This should be fairly simple right?
|
|
|
|
|
Thanks for the answer. It doesn't seem that simple to me. Actually I dont really have a clue what you are talking about. I am storing data into a database that the windows service uses so there is no need for the passing of arguments through the command line. I do not want to "create username/passwords". I want the user to provide his or her windows username, password, and a directory in "Program1.exe" which stores the information in a database. Then "Service1.exe" reads the database finds the username, password, and a directory and then is able to use Directory.Exists() to see if that directory does infact exist. The problem is the specified directory does exist but Directory.Exists() returns false.
|
|
|
|
|
You gotta be kidding.
Geeze, well, wherever NumberOfUnits is declared I have no idea, but it must be your number of rows... and what you are doing is iterating the rows and assigning the value of tb[i].Text.ToString() to the row.
What the hell did you expect to happen?
|
|
|
|
|
I expected exactly what in fact did happen BUT I wasn't seeing what was happening.
The problem was elsewhere - the actual textboxes were bound to the datatable incorrectly SO my code was fine.
The short answer - there was nothing wrong with the code
Glen Harvy
|
|
|
|
|
I guess so, if that was what you intended. But your question "seemed" to suggest you were trying to analyze why that had happened.
Good job, even if you couldn't see what was happening.
Actually, you have to be careful with how you connect things in visual development environments. Visual configuration errors can sometimes be pretty difficult to interpret.
I still don't understand why the array of text boxes... but no matter.
I hope you forgive me. No offense intended.
|
|
|
|
|
No worries mate
Your right - I was trying to analyze it.
Cheers.
Glen Harvy
|
|
|
|
|
I'm trying to open a file pragmatically with an application that is not the default and with out setting it as a default.
For example: I have a myfile.bmp. My default photo viewer is Microsoft Fax Viewer, but I want to open it with Microsoft Paint with out setting Microsoft Paint as the new default.
I've been playing with Process.Start("myfile.bmp") but can't seem to get anything to work.
Any help would be appreciated
Best Regards
-Chris
|
|
|
|
|
You can change file Associations by Shift Right Click. You get a OpenWith in whose target dialog a new association can be saved.
|
|
|
|
|
It's done also with the Process.Start method but with an overload form of it. Basically you must start the application you desire(in your case mspaint.exe) and specify the name of the file you wish to open as a runtime parameter for mspaint.exe.
I've done this once. If I find the code snippet, I'll post it later.
|
|
|
|
|
I posted a question earlier re. genarics for .net 2.0 and seems that what I'm trying to do is unfeasible.
So here's my last (I think it's last) question on generics:
Is it possible to reference "current class" instead of hard-coding the class name in the code?
E.g.
abstract class BaseClass
{
static void GenericStaticMethod < T > (args)
{
...
}
void Foo()
{
GenericStaticMethod <CurrentClass>.(args);
}
}
class C1 : BaseClass
{
...
}
class C2 : BaseClass
{
...
}
when calling C1.Foo() , it should in turn call GenericStaticMethod < C1 > (...) or calling C2.Foo(), it should in turn call GenericStaticMethod < C2 > (...) ?
- Malhar
|
|
|
|
|
I don't think so. The best way to accomplish what you're trying to do is to make Foo() virtual, then override Foo in the base classes to do call GenericStaticMethod<t> using the current class type.
|
|
|
|
|
that's what i was afraid of! i wanted to use generics to the fullest. i wonder why microsoft couldn't have anticipated need for such.
- Malhar
|
|
|
|
|
GenericStaticMethod <this.GetType()>.(args);
Does not work?
/M
|
|
|
|
|
|
I want to display some values like Windows Task Manager - Performance:
Commit Charge (K) -- Peak
Physical Memory (K) -- Total, System Cache
How can I get this values using PerformanceCounter ?
Thanks.
|
|
|
|
|
That would be quite a trick. You would have to descend from PerformanceCounter to build a composite class that got that information for you from the class(es) you should be getting that information from directly. That would sort of be the long way around the problem kinda sorta wouldn't it?
Search your documentation and find the class(es) that do what you need to do. Call their methods or read their properties, and you won't have to design a class that uses that class to find out you can use that class directly.
BTW, here is what your documentation says about PerformanceCounter (I checked, just not to embarrass myself to horribly):
http://msdn2.microsoft.com/en-us/system.diagnostics.performancecounter(VS.71).aspx
If you don't find an appropriate member, your class search has just begun.
|
|
|
|
|
Thanks.
|
|
|
|
|
Hi all,
i have a problem, i need playing mp3 from stream (stream nor mp3 file from my hdd) but i dont now how
I hope anybody can help me with this problem. Sorry for my english .
bb
|
|
|
|
|
Hello ,
Can you please explain more about what you really want to do ??
Regards ,
nishu
|
|
|
|
|
ok i try this
i need play mp3 from memorystream without saving on disk.
Example: load mp3 file to memorystream and play him... All function need string with filepath and this is my problem.
|
|
|
|
|
hi,
I am trying to capture events happening on IE (especially anchor click).
I used typical IHTMLDocumentEvent2_Event method, but unfortunately this method was blocking up mouse activiteis(wheeling, selection and such)
So I tried to use custmoized handler that I found at http://west-wind.com/WebLog/posts/393.aspx[^]
But to do that, I need to access IE.docment.parentWindow to get IHTMLEvetObj.
I am using SHDocVw.InternetExplorer not WebBrowser nor AxWebBrowser, so it did not allow to access the actual IE window to retrieve events.
such as
IHTMLDocument2 document = IE.document as IHTMLDocuemnt2;
then, when I tried to do "document.parentWindow.@event"
I reports InvalidCastException.
Is there any one who has suggestions.
Thanks
|
|
|
|