Opening a folder in Windows Explorer

BlitzMax Forums/BlitzMax Programming/Opening a folder in Windows Explorer

gburgess(Posted 2007) [#1]
I'm trying to get my program to open a specific folder in the Windows Explorer. I can't figure out how to do it. I found mention of CreateProcess and System_ on these forums, but the program just seems to ignore them. Sending the extract same string that I am using with these commands to the 'Run...' dialogue in Windows works (it's basically just a full folder path), I'd just like my program to do it automatically.

Any advice, anyone?


FlameDuck(Posted 2007) [#2]
Sending the extract same string that I am using with these commands to the 'Run...' dialogue in Windows works
Haven't tested it, but have you tried "explorer <pathname>" instead?


tonyg(Posted 2007) [#3]
Strict

Framework Brl.Blitz
Import PUB.FreeProcess

Local Proc:TProcess = TProcess.Create("explorer c:", 0)
Delay 6000

Proc.Terminate()

End


does this do it?


gburgess(Posted 2007) [#4]
Flame, I tried that, and curiosly it tells me the path doesn't exist. Same when I do it from the Run... dialogue, and yet the path on it's own works fine.


tonyg(Posted 2007) [#5]
Did that program not work?
Post your code so we can give it a try.


gburgess(Posted 2007) [#6]
Sorry, tony, haven't got to it, yet. I'll try it in just a minute.


gburgess(Posted 2007) [#7]
This is basically what I'm doing, it's just tagged onto the end of my program, right before it ends:

If Confirm("Would you like to go to the saved pictures folder?")
	System_("explorer "+AppDir$+"/pictures")
	DebugLog AppDir$+"/pictures"
EndIf

End


The Debuglog entry is just to ensure that I'm putting in the right path. Minus the "explorer "+ part of the System_ command, the program quits fine, but without any acknowledgement or indication that the system command happened. With the "explorer "+ part it gives the error mentioned above. Oh, wait, maybe I need to put the argument in speechmarks or something.


FlameDuck(Posted 2007) [#8]
Flame, I tried that, and curiosly it tells me the path doesn't exist.
Remember that if it contains spaces, you need to escape them, or enclose it in double-quotes.


gburgess(Posted 2007) [#9]
Ah, no, it's the '/' characters. Explorer doesn't seem to like them in the arguments, it prefers '\'.

Yup, that fixed it. Adding "explorer" was the solution, thanks, guys!

Bizarrely, while there is a space, it doesn't seem to need double quotes, it works fine. Which I wouldn't have expected.


SebHoll(Posted 2007) [#10]
Just call [b]OpenURL(path){/b]. I.e.

OpenURL("C:\Windows")
will open explorer to the Windows directory.