Hi there,
My application gets the file list from the actual folder Windows Explorer is pointed to. It is working well.
I just need to programmatically change the Windows Explorer View Mode to "Details", on that external Windows Explorer task.
I have already searched VB forums and found nothing about. Thanks for any help.
This is my code:
My application gets the file list from the actual folder Windows Explorer is pointed to. It is working well.
I just need to programmatically change the Windows Explorer View Mode to "Details", on that external Windows Explorer task.
I have already searched VB forums and found nothing about. Thanks for any help.
This is my code:
VB.NET:
Imports System.IO
Imports System.IO.FileAttributes
Imports System.IO.File
Imports System.IO.Directory
Imports Shell32 ' for ShellFolderView
Imports SHDocVw ' for IShellWindows
Imports System.Text.RegularExpressions
Public Class frmViewMode
Private Sub ViewMode_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim strActiveExplorerFolder As String
strActiveExplorerFolder = GetExplorerPath() ' Actual folder Windows Explorer is pointed to
If strActiveExplorerFolder <> "" Then LoadFiles(strActiveExplorerFolder)
' Here I need some code to change the Windows Explorer View Mode to "Details",
' no matters the actual view mode setting.
End If
End Sub
Private Function GetExplorerPath() As String
Dim exShell As New Shell
Dim expPath As String
For Each w As ShellBrowserWindow In DirectCast(exShell.Windows, IShellWindows)
If TryCast(w.Document, IShellFolderViewDual) IsNot Nothing Then ' try to cast to an explorer folder
expPath = DirectCast(w.Document, IShellFolderViewDual).FocusedItem.Path
Return Path.GetDirectoryName(expPath) ' remove GetDirectoryName method to return selected file rather than folder
ElseIf TryCast(w.Document, ShellFolderView) IsNot Nothing Then
expPath = DirectCast(w.Document, ShellFolderView).FocusedItem.Path
Return Path.GetDirectoryName(expPath)
End If
Next
Return ""
End Function
Private Sub LoadFiles(ByVal strFolder as string)
' my code here to get and work with the file list
End Sub
End Class