Saturday, 5 November 2016

C# computer owner name




I have one problem..
I have image converting program so if one user converting image file then his computer name going into file name.'




Something like this I need:
John-Doe.23-07-2016.JPG



But at the moment taking computer name like this: John-Doe/John-Doe.23-07-2016.JPG



My code:



string user = File.GetAccessControl(textBox1.Text).GetOwner(typeof(NTAccount)).ToString();



textBox1.Text is place where program choosing folder where is image files.


Answer



You say you want the computer name, yet you use username.



You should look into the values in System.Environment. There you can get the username using System.Environment.UserName, or the computer name using System.Environment.MachineName


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...