shellexecute open a folder and search files
Posted:
Fri May 24, 2024 2:00 pm
by MarcoBoschi
Hi,
is it possible to launch shellexecute that opens a folder and to perform immediately a search for a file mask passed as parameters?
For Instance Open f:\myapp\report\ folder and search all files 202405*.pdf
Bye
Re: shellexecute open a folder and search files
Posted:
Fri May 24, 2024 2:41 pm
by Willi Quintana
HI,
You could use the "directory" function
aFiles := DIRECTORY( "f:\myapp\report\" + "202405*.pdf")
Re: shellexecute open a folder and search files
Posted:
Fri May 24, 2024 2:54 pm
by MarcoBoschi
Dear Willy my intent is to open folder I want to permit to user to see the folder but I wanto to help him setting a filter in the list o files present in it
Many thanks for your answer
Marco
Re: shellexecute open a folder and search files
Posted:
Fri May 24, 2024 3:02 pm
by karinha
Look at this example if it helps you.
Mira este ejemplo si te ayuda.
- Code: Select all Expand view
// C:\FWH\SAMPLES\MARCOBOS.PRG#include "FiveWin.Ch"#include "Directry.ch"#define CLR_LGREEN nRGB
( 190,
215,
190 )#define CLR_LGRAY nRGB
( 230,
230,
230 )#define CLR_VERMELHO nRGB
( 255,
000,
000 )#define CLR_AMARELO nRGB
( 255,
255,
000 )REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
STATIC nBytes, nDisks
STATIC lnKeyEscape := .F.
FUNCTION Main
() LOCAL oSetupDlg, nDriveTo :=
1, cDriveTo, nDriveCap :=
4 LOCAL lGoOn, aFiles
[ 1 ], aFileList, x, iDcor, oFont, oBackup
LOCAL oDlg, oBrw, n :=
1 LOCAL oAceitar, oCancelar, nKey := VK_RETURN
LOCAL aPdfs := Directory
( "C:\TEMP\*.PDF" ) // LOCAL aPdfs := DirectoryRecurse( "C:\FWH1701\*.*" ) // LOCAL aPdfs := DirectoryRecurse( "*.PDF" ) SET CENTURY
ON // SET DATE BRITISH SET DATE AMERICAN
SET TIME FORMAT
TO "HH:MM:SS" SET EPOCH
TO Year( Date
() ) -
30 SET SOFTSEEK OFF
SET WRAP
ON SetCancel
( .F.
) SET CONFIRM OFF
SET DELETED
ON SET _3DLOOK
ON SET UNIQUE OFF
SET ESCAPE OFF
SET EXACT
ON SET EXCLUSIVE OFF
SET MULTIPLE OFF
SkinButtons
() IF Len
( aPdfs
) <
1 RETURN NIL ENDIF // aSort( aPdfs, , , { |x, y | x[1] < y[1] } ) ASort
( aPdfs
) DEFINE FONT oFont
NAME "Arial" SIZE 0,
16 BOLD
DEFINE DIALOG oDlg
FROM 6,
20 TO 25,
90 ;
TITLE "PDFs File Browser at: " + ;
CurDir
() +
" To View" ;
STYLE nOR
( WS_BORDER, WS_THICKFRAME
) ;
COLORS CLR_BLACK, nRGB
( 193,
205,
205 ) @
1,
2 LISTBOX oBrw FIELDS aPdfs
[ n
][ 1 ], ;
Str
( aPdfs
[ n
][ 2 ],
10,
0 ), ;
DToC
( aPdfs
[ n
][ 3 ] ), ;
aPdfs
[ n
][ 4 ] ;
Headers
"File Name", ;
"Size",
"Date",
"Hour" ;
FIELDSIZES
270,
80,
80,
60 ;
COLOR CLR_HBLUE, CLR_AMARELO ;
FONT oFont ;
Of oDlg
Size 260,
100 oBrw:
bGotop :=
{|| N :=
1 } oBrw:
bGoBottom :=
{|| N := Eval
( oBrw:
bLogicLen ) } oBrw:
bSkip :=
{| nWant, nOld | nOld := N, N += nWant, ;
N :=
Max( 1,
Min( N, Eval
( oBrw:
bLogicLen ) ) ), ;
N - nOld
} oBrw:
bLogicLen :=
{|| Len
( aPdfs
) } oBrw:
cAlias :=
"Array" oBrw:
nClrBackHead := CLR_LGREEN
oBrw:
nClrBackFocus := CLR_HRED
oBrw:
nClrForeFocus := CLR_AMARELO
oBrw:
nClrForeHead := CLR_HRED
oBrw:
nColAct :=
1 oBrw:
nLineStyle :=
3 oBrw:
lCellStyle := .T.
oBrw:
aJustify :=
{ .F., .F., .F., .F.
} oBrw:
lMChange := .F.
oBrw:
SetFocus() oBrw:
Refresh() @
6.6,
20 Button oBackup
PROMPT "&Exit" Of oDlg ;
ACTION( oDlg:
End() ) SIZE 40,
12 CANCEL
ACTIVATE DIALOG oDlg
CENTERED oFont:
End()RETURN NIL// FIN / END - kapiabafwh@gmail.com
Regards, saludos.
Re: shellexecute open a folder and search files
Posted:
Fri May 24, 2024 3:13 pm
by MarcoBoschi
Thank you too but my goal is to have an opened explorer folder
Re: shellexecute open a folder and search files
Posted:
Wed May 29, 2024 9:30 am
by Silvio.Falconi
karinha wrote:+1
- Code: Select all Expand view
// C:\FWH\SAMPLES\VISUALPDF.PRG
#Include "FiveWin.ch"
FUNCTION Main()
LOCAL cPathImg, cDirPDfs
cDirPDfs := "C:\TEMP" // GETCURDIR()
IF SUBS( cDirPDfs, LEN( ALLTRIM(cDirPDfs ) ) , 1 ) = "\"
cDirPDfs := SUBS( cDirPDfs, 1 , LEN( ALLTRIM(cDirPDfs ) ) - 1 )
ENDIF
LCHDIR( cDirPDfs )
cPathImg := cDirPDfs + "\"+ "*.PDF"
cFile := cGetFile( "PdfFile(*.Pdf)|*.Pdf|", ;
"Select a File", CurDir(), .T. )
RETURN NIL
// FIN / END
Regards, saludos.
If I need only the folder ? I tried with it but not run only to take a file