|
-
Jan 11th, 2005, 07:50 AM
#1
Thread Starter
Member
user name
Is there a way that I can get the directory name of the user name? I know that if you want the windows folder you use %system directory% can I do that for a user? This is my code
VB Code:
Private Sub brnCleanAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles brnCleanAll.Click
Dim DirInfo As New IO.DirectoryInfo("C:\Documents and Settings\tony\Cookies") 'file path
Dim filesCompleat As Integer ' number of times it went through a loop
PB1.Maximum = 'number of files
For Each File As IO.FileInfo In DirInfo.GetFiles("*.txt")
File.Delete() 'deletes text files
PB1.Maximum += 1
Next
End Sub
I also need to know how I can find the total number of files before the loop starts
Last edited by tonyrueb; Jan 11th, 2005 at 04:24 PM.
-
Jan 11th, 2005, 08:52 AM
#2
Re: user name
Environment.UserName 
Why don't people ever use MSDN?
I don't live here any more.
-
Jan 11th, 2005, 04:22 PM
#3
Thread Starter
Member
Re: user name
In not all cases that will work. On a dual boot computer with like 2000 and xp they both use the same folder so if you had 2 users one on 2000 and one on xp both named Tony one user will be some like tonyComputerName just so you know for further reference and thanks for the help
-
Jan 11th, 2005, 04:29 PM
#4
Frenzied Member
Re: user name
If all you are trying to do is get the users cookie directory. Try this
VB Code:
MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.Cookies).ToString())
-
Jan 12th, 2005, 06:48 AM
#5
Lively Member
Re: user name
Not entirely sure if this is what you're asking or not. What I have done in the past is used the Application.UserAppDataPath and then split the returned value into a string array with the backslash character as a delimiter. The second member of the array should contain the username as it appears in the domain or workgroup.
Joe Cody
Data Integration Engineer
Novaspect, Inc.
Elk Grove Village, IL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|