|
|
Hi greetings to all [ ];
I am working on a client-Server Project.... (C#.net/SQL)
Need to know ::
1. how can i start the Client(.net) application(s) on a LAN from server application(.net)
2. How to run a particular service(Windows) on the client machine from server (which in turn can communicate with the already running client application)
Thanks n Regards,
Aamu
|
|
|
|
|
hi , Thanks in advance for everyone who reads that!
How can i set a thread so that when i start it the calling thread returns to what it did before and the new thread continues from that point , or any other solution with similar effect ?
for example:
<br />
<br />
public void Some_Event(Object sender , EventArge e)<br />
{<br />
Console.writeline("Im the Old Thread: {0}",Thread.CurrentThread.Name);<br />
<br />
Console.writeline("Im the new Thread: {0}",Thread.CurrentThread.Name);<br />
<br />
SomeForm sf = new SomeForm(((String)sender).username);<br />
<br />
}<br />
<br />
Net
|
|
|
|
|
Google finds this.[^]
You might also want to look at the TreadPool class (Google it). It provides a bit less control over the treads, but in returns handles queuing requets, creating threads etc automatically.
|
|
|
|
|
if i wouldnt read that msdn or google i wouldnt ask here ,
in the msdn they only show examples of
Thred t = new thread(ThreadStart(target));
if you read my question i need something a bit different , dont know if its possible thats why im asking.
Net
|
|
|
|
|
beleive me, a lot of people do NOT consult MSDN or Google before asking, you are the (positive) exception here.
But to answer your question - No, you do not need anything different.
Where you have written "//Some code i dont know how to implement" the code (pseudo code, I am not sure delegate names and signatures match - find them in MSDN) is as follows:
<br />
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadMethod));<br />
}
<br />
private void ThreadMethod()
{<br />
}<br />
Depoending on how much control you want with the thread, you can use one of the alternatives (create a Thread object etc) instead of the ThreadPool.
If you REALLY want it in the same method you can replace the "new WaitCallback(ThreadMethod)" part with an anonymous delegate. But I really recommend you try to think of starting threads as follows:
1) The creating thread continues execution in the current method
2) The new thread starts running in a new method/scope.
it will help you later on as this is how the thread methods are designed - and how they are used by most developers.
|
|
|
|
|
The anonymous delegate did the trick ,
Thanks
i did something like that if that's what you mean:
<br />
public void my_multi_threaded_method()<br />
{<br />
Console.WriteLine("calling thread");<br />
<br />
Thread t = new Thread(ThreadStart(delegate() <br />
{<br />
Console.WriteLine("child thread");<br />
});<br />
t.start<br />
}<br />
Net
|
|
|
|
|
plz any ine help me
i need a code for finding whether a file is exisisting in the folder if exist display the file woth some text or not create the file with some text and displaying message that file is created successfully using c#
|
|
|
|
|
you can use System.IO.File.Exists(string path) method to check whether the file exists or not.
good luck
|
|
|
|
|
using System;
using System.IO;
using System.Collections;
public class FileHandling
{
public static void Main(string[] args)
{
foreach(string path in args)
{
if(File.Exists(path))
{
// Your code should run here
}
else if(Directory.Exists(path))
{
//Your code should run here
}
else
{
Console.WriteLine("{0} is not a valid file or directory");
}
}
}
Happy Programming
-----
Abhijit
|
|
|
|
|
|
you must first set the WorkerSupportsCancellation Property of BackgroungWorker instance to true.
then you can cancel it
good luck
|
|
|
|
|
Hessam Jalali wrote: you must first set the WorkerSupportsCancellation Property of BackgroungWorker instance to true.
C'mon, I might have screwed up a bit lately but I'm not that stupid
OF COURSE I DID! Yet, it's not working
Thanks anyways Hessam:->
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
really sorry, I didn't mean that ,I make these type of careless mistakes alot myself
can you send some code?
|
|
|
|
|
|
How do you do it guys ..
Clipboard.SetText("C:\SomeFile.txt"); just doesnt seem to work
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
|
Clipboard.SetFileDropList((System.Collections.Specialized.StringCollection) "C:\test.txt");
Still dont know how to do it
Thanks pmarfleet
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
You can't just cast your string however to whatever type you want it to be.
I haven't used the function myself, by but reading the documentation it should work like that:
StringCollection coll = new StringCollection();<br />
coll.Add("C:\\Test");
Clipboard.SetFileDropList(coll);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks Greeeeeeeeeeeeeeeeeeeeeg
I'm trying it now, it should work right;)
Thanks a bunch buddy
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
I need to obtain the fully list of users and groups in a Server, like you see on Users & Groups, in computer management of control
pannel. And the user in the particular group.
Any help or idea is greatly appreciated
Thanks in advance
Surya
|
|
|
|
|
you can do that using WMI through System.Management namespace (you must add it as reference)
you can query Win32_UserAccount and Win32_UserGroup from WMI for collecting your data
maybe this is not the best solution but it's going to work
here is the code
public class UserManagements
{
public class GroupUser
{
const string PATTERNNAME = ".*Name=\"(?'name'.*)\".*";
const string PATTERNDOMAIN = ".*Domain=\"(?'domain'.*)\",.*";
public readonly string groupName;
public readonly string partName;
public readonly string groupDomain;
public readonly string partDomain;
public GroupUser(string groupComponent, string partComponent)
{
this.groupName = Regex.Replace(groupComponent, PATTERNNAME, "${name}");
this.partName = Regex.Replace(partComponent, PATTERNNAME, "${name}");
this.groupDomain = Regex.Replace(groupComponent, PATTERNDOMAIN, "${domain}");
this.partDomain = Regex.Replace(partComponent, PATTERNDOMAIN, "${domain}");
}
}
public class UserAccount
{
public readonly int AccountType;
public readonly string Caption;
public readonly string Description;
public readonly bool Disabled;
public readonly string Domain;
public readonly string FullName;
public readonly bool LocalAccount;
public readonly bool Lockout;
public readonly string Name;
public readonly bool PasswordChangeable;
public readonly bool PasswordExpires;
public readonly bool PasswordRequired;
public readonly string SID;
public readonly int SIDType;
public readonly string Status;
public UserAccount(ManagementObject userMO)
{
this.AccountType = Convert.ToInt32(userMO.Properties["AccountType"].Value);
this.Caption = userMO.Properties["Caption"].Value as string;
this.Description = userMO.Properties["Description"].Value as string;
this.Disabled = Convert.ToBoolean(userMO.Properties["AccountType"].Value);
this.Domain = userMO.Properties["Domain"].Value as string;
this.FullName = userMO.Properties["FullName"].Value as string;
this.LocalAccount = Convert.ToBoolean(userMO.Properties["LocalAccount"].Value);
this.Lockout = Convert.ToBoolean(userMO.Properties["Lockout"].Value);
this.Name = userMO.Properties["Name"].Value as string;
this.PasswordChangeable = Convert.ToBoolean(userMO.Properties["PasswordChangeable"].Value);
this.PasswordExpires = Convert.ToBoolean(userMO.Properties["PasswordExpires"].Value);
this.PasswordRequired = Convert.ToBoolean(userMO.Properties["PasswordRequired"].Value);
this.SID = userMO.Properties["SID"].Value as string;
this.SIDType = Convert.ToInt32(userMO.Properties["SIDType"].Value);
this.Status = userMO.Properties["Status"].Value as string;
}
}
public static GroupUser[] GetGroupUsers()
{
List <GroupUser> groupUsers = new List <GroupUser>();
ManagementObjectSearcher mos = new ManagementObjectSearcher(new SelectQuery("Win32_GroupUser"));
ManagementObjectCollection moc = mos.Get();
foreach (ManagementObject mo in moc)
{
string groupComponent = mo.Properties["GroupComponent"].Value as string;
string partComponent = mo.Properties["PartComponent"].Value as string;
GroupUser gu = new GroupUser(groupComponent, partComponent);
groupUsers.Add(gu);
}
return groupUsers.ToArray();
}
public static UserAccount[] GetUserAccounts()
{
List <UserAccount> userAccounts = new List <UserAccount>();
ManagementObjectSearcher mos = new ManagementObjectSearcher(new SelectQuery("Win32_UserAccount"));
ManagementObjectCollection moc = mos.Get();
foreach (ManagementObject mo in moc)
userAccounts.Add(new UserAccount(mo));
return userAccounts.ToArray();
}
}
you can use it through GetUserGroups and GetUserAccounts methods.
hope the post would be useful
-- modified at 6:02 Saturday 6th October, 2007
|
|
|
|
|
Hi,
I'm trying to select an item in a listbox control by right clicking on it, can you please tell me what's wrong with what I'm doing??
private void listbox1_MouseClick(object sender, MouseEventArgs e)
{
listbox1.SelectedItem = listbox1.GetChildAtPoint(listbox1.PointToClient(e.Location));
}
Thank you guys!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi
I suggest to use MouseDown or MouseUp events instead of Click because they give you the mouse button and position all together
and you can find the index of pointed item by using IndexFromPoint method of listBox instance
here is the code I tested to see how it can be done
void listBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Right) return;
int index=this.listBox1.IndexFromPoint(e.Location);
if (index == -1) return;
object selectedObj = this.listBox1.Items[index];
this.listBox1.SelectedIndex = index;
MessageBox.Show(selectedObj.ToString());
}
good luck
|
|
|
|
|
GREATE
listbox1.SelectedIndex = listbox1.IndexFromPoint(e.Location);
Wish I can give you 6
Thanks a million Hessam!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|