Results 1 to 5 of 5

Thread: user name

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    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:
    1. Private Sub brnCleanAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles brnCleanAll.Click
    2.         Dim DirInfo As New IO.DirectoryInfo("C:\Documents and Settings\tony\Cookies") 'file path
    3.         Dim filesCompleat As Integer ' number of times it went through a loop
    4.         PB1.Maximum = 'number of files
    5.  
    6.         For Each File As IO.FileInfo In DirInfo.GetFiles("*.txt")
    7.             File.Delete() 'deletes text files
    8.             PB1.Maximum += 1
    9.         Next
    10.  
    11.     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.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: user name

    Environment.UserName


    Why don't people ever use MSDN?
    I don't live here any more.

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    46

    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

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256

    Re: user name

    If all you are trying to do is get the users cookie directory. Try this
    VB Code:
    1. MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.Cookies).ToString())

  5. #5
    Lively Member
    Join Date
    Aug 2003
    Location
    Chicago, IL
    Posts
    102

    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
  •  



Click Here to Expand Forum to Full Width