0

Ok so i want to create a file

File.Create("..."):

I want it to be able to detect the user that is on so it automatically creates it on there desktop. Is this possible.

2
Contributors
2
Replies
4
Views
12 Years
Discussion Span
Last Post by tayspen
0
// Creates a file called "test.txt" on the currently logged-in
// user's desktop
File.Create(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\testfile.txt");

// Or if you only want to find out the user that is currently logged in
String userName =  Environment.GetEnvironmentVariable("username");
0
// Creates a file called "test.txt" on the currently logged-in
// user's desktop
File.Create(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\testfile.txt");

// Or if you only want to find out the user that is currently logged in
String userName =  Environment.GetEnvironmentVariable("username");

Ok, Thank that was easy enough.


Thanks


-T

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.