Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[38] Advanced Files & Folders

Last post 07-28-2006 2:30 PM by unitled. 14 replies.
Page 1 of 1 (15 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [38] Advanced Files & Folders

    This thread is for discussions of Advanced Files & Folders.

    • Post Points: 55
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 09-16-2002 12:45 PM In reply to

    How do you Open a Folder on the Desktop?

    This is a a great tutorial, but how do you open up a folder on a persons desktop? Shell Execute will launch programs, but if you wanted to open up a folder like Installshield does at the end of installing a program. How is that done?


    Thanks

    -DP
    • Post Points: 0
  • 04-13-2003 3:54 PM In reply to

    Forgot something!

    In the code for checking if a file exists (page "Does it exist?") the first part needs this added to it near the start:
    Code:
    dim strPath as string
    I put it right after "Dim sStartDir As String" and it worked perfect.
    • Post Points: 0
  • 07-07-2003 10:21 AM In reply to

    • lae0502
    • Not Ranked
    • Joined on 01-30-2003
    • New Member
    • Points 5

    Re: How do you Open a Folder on the Desktop?

    Normally, the folders on the Desktop are stored on the systems partition. So you have to find out which it is. Then you have to find out, the username of the currently loggod in user, because the desktop folders (for example in the german version of W2k) are stored in "[SystemPartition]:\Dokumente und Einstellungen\[Username]\Desktop".

    To archive your goal, you paste the Code below into a module and call the function "getdesktopfolder" which returns a string. If you are using another version of Windows, you have to find out the equivalent path to "Dokumente und Einstellungen".

    Lars

    Private S1 As String
    Private Declare Function GetUserName Lib "AdvAPI32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Public Function FindUserName() As String
     S1 = Space(512)
     GetUserName S1, Len(S1)
     FindUserName = Trim$(S1)
    End Function

    Public Function GetWindowsDirectory() As String
      Dim s As String
      Dim c As Long
      s = String$(MAX_LENGTH, 0)
      c = GetWindowsDirectoryB(s, MAX_LENGTH)
      If c > 0 Then
          If c > Len(s) Then
              s = Space$(c + 1)
              c = GetWindowsDirectoryB(s, MAX_LENGTH)
          End If
      End If
      GetWindowsDirectory = IIf(c > 0, Left$(s, c), "")
    End Function

    Public Funtion getdesktopfolder() As String
       a = GetWindowsDirectory
       a = Left(a, 3)                                              'extract drive letter
       a = a & "\Dokumente und Einstellungen\"
       a = a & FindUserName & "\Desktop"
       getdesktopfolder = a
    End Function
    • Post Points: 0
  • 07-09-2003 10:58 AM In reply to

    Or...

    Shellexecute explorer.exe PathToFolder
    • Post Points: 0
  • 07-28-2003 5:24 AM In reply to

    No progress bar at all

    How can I get rid of the progress dialog, so the user basically has no indication the operation is being performed?
    [edit] Nevermind. ^_^
    • Post Points: 0
  • 11-10-2003 8:49 PM In reply to

    Can i know this?

    yah, i wanted to search through a root folder for files in the sub folders within folders of the root folders..

    i need to pass the filenames and their directories into an Access2000 table[.mdb].

    Can u guys please help me? I'm very new to VB.NET and i need to get this done by VB.NET... thanks in advance...
    • Post Points: 0
  • 02-03-2004 5:55 PM In reply to

    • jawsper
    • Not Ranked
    • Joined on 04-11-2003
    • Junior Member
    • Points 25

    to get the desktop folder....

    first add this (in a module):
    Code:

    Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    Public Type SHITEMID
       cb As Long
       abID As Byte
    End Type
    Public Type ITEMIDLIST
       mkid As SHITEMID
    End Type
    Public Const MAX_PATH As Integer = 260
    Private Const CSIDL_PROGRAM_FILES = &H26 ' Program Files
    Private Const CSIDL_STARTMENU = 11 ' Start Menu
    Private Const CSIDL_DESKTOP = &H0 ' The Desktop


    then, in the form:
    Code:

    Public Function fGetSpecialFolder(CSIDL As Long) As String
       Dim sPath As String
       Dim IDL As ITEMIDLIST
       fGetSpecialFolder = ""
       If SHGetSpecialFolderLocation(frmMain.hWnd, CSIDL, IDL) = 0 Then
           sPath = Space$(MAX_PATH)
           If SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath) Then fGetSpecialFolder = Left$(sPath, InStr(sPath, vbNullChar) - 1) & ""
       End If
    End Function

    then to get the desktop folder (or start menu or program files):
    Code:

    string_desktop_folder = fGetSpecialFolder(CSIDL_DESKTOP)
    string_startmenu_folder = fGetSpecialFolder(CSIDL_STARTMENU)
    string_prog_files_folder = fGetSpecialFolder(CSIDL_PROGRAM_FILES)

    easy, not??
    (i found this somewhere on this site.. i didn't make this myself)
    ----------------------------------
    so, why arent you reading my extremely interesting post above? ;)
    • Post Points: 0
  • 02-03-2004 8:56 PM In reply to

    • Michael H
    • Top 50 Contributor
    • Joined on 01-19-2002
    • Guru
    • Points 1,995
    I'm surprised no one said "double click"...
    • Post Points: 0
  • 02-04-2004 11:38 PM In reply to

    • clec
    • Not Ranked
    • Joined on 02-04-2004
    • New Member
    • Points 5

    no progress bar

    did anyone solve this one as I need it too?  Should we be using a different api?
    • Post Points: 0
  • 08-08-2004 1:27 AM In reply to

    Minor bugs

    Hi,
    Couple of small bugs -

    Change  Dim sPath As String   to    strPath

    Change ""  to  "\" in two lines -
           sStartDir = Left$(sFile, InStrRev(sFile, ""))
           '// just get filename
           sFile = Right$(sFile, Len(sFile) - InStrRev(sFile, ""))

    Regards,
    Rob
    • Post Points: 0
  • 09-22-2004 5:38 AM In reply to

    • vor0nwe
    • Not Ranked
    • Joined on 09-22-2004
    • New Member
    • Points 5

    How does one actually Undo?

    Hi,

    This code snippet works all right.  What I’m looking for, however, is how to actually Undo a file operation?  I can’t find any way to do that by code...

    Thanks for all tips!

    vor0nwe
    • Post Points: 0
  • 11-26-2004 10:28 AM In reply to

    I think you use the FOF_SILENT flag. Been a while since I did it though.
    • Post Points: 0
  • 11-26-2004 10:29 AM In reply to

    I think you use the FOF_SILENT flag. Been a while since I did it though.
    • Post Points: 0
  • 07-28-2006 2:30 PM In reply to

    • unitled
    • Not Ranked
    • Joined on 07-28-2006
    • New Member
    • Points 5

    Re: [38] Advanced Files & Folders

    Okay, I've used the 'List all files in a directory' code (with a few slight modifications) but whenever I reboot the computer, it stops finding the files that are there (other than that, it works fine). It only finds them again if I rename the files. I figure it might be because I'm using a computer at University with some strange access priviledges. Any help is much appreciated.
    • Post Points: 5
Page 1 of 1 (15 items)