|
|
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)
(><)
|
|
|
|
|
Error:No connection could be made because the target machine actively refused it
code is given below:
MailMessage message = new MailMessage(emailid, "rajeshvyas2005@yahoo.co.in",
txtsub.Text,txtbdy.Text);
message.Attachments.Add(new Attachment(filupldatchmnt.PostedFile.FileName));
SmtpClient client = new SmtpClient();
client.Host = "80.36.278.159";
client.Port = 4576;
client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
client.Send(message);
Response.Write("Message sent");
Rajesh Vyas
|
|
|
|
|
This means your mail server configuraton is wrong.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Rajesh Ji wrote: Error:No connection could be made because the target machine actively refused it
It means there is no SMTP service running on 80.36.278.159:4576.
|
|
|
|
|
Hello Everyone,
Can anyone tell what is the importance of the delegate in C# and also which situations we should use it in...................
|
|
|
|
|
Have you read the MSDN documentation[^]? If you don't know what delegates are, this should be your starting point.
You really shouldn't ask questions like this though. A quick Google search would have yielded plenty of resources on delegates and their usage.
Paul Marfleet
|
|
|
|
|
Buy a book and work through it. This is not the sort of thing that is easily explained in an off the cuff forum reply, and it's pretty fundamental.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi all,
Is there any way to detect File Copy or move from a particular direcotry using FileSystemWatcher !!!!
Thanks in Advance !!!
Happy Programming
-----
Abhijit
|
|
|
|
|
I don't think you can tell, just by watching the target directory, whether a file being created there has been moved or copied from another directory. If you knew where the files were coming from, you could set up a FileSystemWatcher on the source directory. You could then detect a file move by watching for a delete event on the source directory and a create event on the target directory. You would be able to detect file being coped though. If you don't know where the files are coming from, then this approach won't work.
Paul Marfleet
|
|
|
|
|
Thank for your reply !!!
but is there no way to detect for the same !!!!
Happy Programming
-----
Abhijit
|
|
|
|
|
FROM a particular directory, no there isn't. You can tell if the file shows up in the target directory though, if the FileSystemWatcher is looking at it.
|
|
|
|
|
I'm using XNA game studio but when i try to compile a simple window with a image. It tells me there is a error in the Microsoft.XNA.Framework.Content.Pipeline. And the first time i tried it said the pipeline exetenion wasn't installed.
Can anyone give me a answer to this question??? Plz!!!!
Michael
(Up and coming Game programmer)
EST
|
|
|
|
|
I know this is an easy question, but what is the operator for 'or'? Please no hassle, just answer... Thanks...
|
|
|
|
|
one of these |
If your using it in an if statement, like: if(a == b OR a == c)
then you need to use two of them, just like with the equals sign, or the AND sign.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
This isn't quite correct. C# supports both the bitwise (|) and conditional (||) OR operators. They can both be used for logical operations. The difference is that the conditional OR operator performs short-circuit evaluation. This means that if the first expression evaluates to TRUE then the second expression will not be evaluated, as the overall result of the operation will be true regardless of the value of the second expression. The bitwise operator, as its name suggests, is typically used for bitwise operations. For general-purpose programming, it is preferable to use the conditional operator as its short-circuit evaluation is more efficient.
Paul Marfleet
|
|
|
|