![]() |
Show File in Window
I have the path to a file, say C:\path\to\file.txt. I need a way to open the folder where that file (file.txt) resides, and select it.
Since I am on a Windows machine, I can use the webbrowser module to load a path: :
import webbrowserThanks in advance. I'm not even sure this is possible in Python. |
Oh, err that sounds really strange. I couldn't see why there'd be support for something like that. If someone knows something in the win32api to prove me wrong, that'd be cool. :)
Otherwise, I'd think it would call for something really obscure. Like synthesizing a keystroke using win32api.keybd_event. First off, have you ever used an application that does what you are trying to do? That might be a helpful clue as to if it is even possible. |
I'm not sure if it's the same in Windows, but on my Mac, when I download a file in my browser, I can go to the Download Manager window and click "Show File in Finder," and it will open a window with the file I just downloaded, selected. I'm trying to do something similar, although it's probably not going to be possible...
|
LaunchServices looks promising. Mac only, though.
|
That does sound pretty obscure. If i'm not mistaken the explorer uses a HTML rendering widget to display the folders and stuff? If you could find a way to get a reference to that rendering widget you could find a way to call some JavaScript in it and focus the folder. It'd be a pretty involved process though.
|
On the InternetExplorer you can click on File/Properties.
|
Huh... Dietrich? What does that have to do with anything at all...? :S
|
Perhaps you want to execute "explorer.exe /select, C:\path\to\file.txt" ?
Note the comma, as per MSKB. I dunno how to do it in python, but that should get you what you want. |
Oh wow! That's amazing, it works. :p So easy... so the code would then be...
:
Edit: I'll post the code for if the path has spaces in it, when I get back from dinner. Post Edit: Oh! Nvm. It works with spaces already. :o |
Wow, thanks... I didn't think it was going to be possible! I'll try this out as soon as I get to work on Monday.
|
| All times are GMT -5. The time now is 12:55 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC