|
Post by honky on Jul 8, 2023 10:57:01 GMT
Good morning, I have a ".txt" file on the desktop, and that I don't want to put elsewhere. Can you give me exampleS of complete paths to access the file with JB/LB. Note: The file is hidden, is that a problem ?
Thank you for...
|
|
|
Post by xxgeek on Jul 8, 2023 13:57:19 GMT
The complete path to the desktop varies with each user, so first we need to GET the path. Usually the path to the desktop\MyTextFile.txt would look something like this: "c:\Users\YOUR-WINDOWS-Username\Desktop\MyTextFile.txt"
Hidden or not, doesn't matter. This code should get your file and open it in notepad. But first, you need to change the name of the file from MyTextFile.txt to the name of the file on YOUR desktop.
global upath$ call getUserProfile print upath$ upath$ = trim$(upath$) run "notepad ";upath$;"\Desktop\MyTextFile.txt" 'change MyTextFile.txt to the name of YOUR file. end
'get users homepath sub getUserProfile run "cmd.exe /c echo %userprofile% >UserHomePath.txt", HIDE do scan loop until fileExists(DefaultDir$, "UserHomePath.txt") open "UserHomePath.txt" for input as #1 upath$ = input$(#1, lof(#1)) close #1 if upath$ = "" then notice "Sorry, can't find user desktop path " : end kill DefaultDir$;"\UserHomePath.txt" end sub
'function for checking file existence function fileExists(path$, filename$) dim info$(0, 0) files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function
|
|
|
Post by honky on Jul 9, 2023 10:50:38 GMT
Thank you , I try...
EDIT: Wonderful it works !
|
|