Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93660

Re: Trouble getting to windows My Documents directory

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <random832@fastmail.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:getting': 0.07; '"my': 0.09; 'indicates': 0.09; 'received:internal': 0.09; 'hresult': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'osx': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'subject:windows': 0.16; 'versions': 0.20; 'windows': 0.20; 'ctypes': 0.22; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'linux': 0.26; '(e.g.': 0.27; 'correct': 0.28; 'raise': 0.29; "i'm": 0.30; 'print': 0.30; 'folder': 0.30; 'skip:[ 10': 0.31; 'generally': 0.32; 'language.': 0.32; 'older': 0.32; 'skip:c 30': 0.35; 'path': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'mac': 0.37; 'received:66': 0.38; 'test': 0.39; 'skip:x 10': 0.40; 'to:addr:python.org': 0.40; 'from:no real name:2**0': 0.60; 'header:Message-Id:1': 0.61; 'provide': 0.61; 'documents': 0.61; 'guaranteed': 0.67; 'foreign': 0.69; 'now)': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=ZsnciowtT1OGM/ATyNGdbKuSbLA=; b=LSZVz2 TLNVuuT46ekqfTq7u/D4GT66HAhrDzvvyN2mkdoXxnzMqe12SdaBhig1BPbxST5O ZcTTVcU4bfmxBswZ9DgJGkYPe8AZCpM7TA0xOnlHQ2o866ks7sfAaVOK/3VmJsQ4 rC2VtMmCwUwAAYUeWGOEZS6pWXLXI7O87JXv0=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=ZsnciowtT1OGM/A TyNGdbKuSbLA=; b=ig8OhVd3EEDLT+ZZMtXD/lKBArnwlkLlHXLEaiCoiiEALOk 9jZe+9qzUAziG/LJEhJ9ilWLyy3rrLDy8Mf03vRrcpXT6F7/3gfi7YGXtLBXaQ/e KzQNYvCat/eNw3ZQkyEyVaaHHCRNXFoA15atMTWWPJA/F2VHcnkYR9Avpz0c=
X-Sasl-Enc r0mCUBZZnW9EEWghdRzrNgGepauILIcy0qtw92ubpyZF 1436574244
From random832@fastmail.us
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-bfc056ae
In-Reply-To <20150710094607.66e62712@bigbox.christie.dr>
References <mstorkamp-154B4A.09272010072015@88-209-239-213.giganet.hu> <20150710094607.66e62712@bigbox.christie.dr>
Subject Re: Trouble getting to windows My Documents directory
Date Fri, 10 Jul 2015 20:24:04 -0400
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.408.1436574781.3674.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1436574781 news.xs4all.nl 2856 [2001:888:2000:d::a6]:57961
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:93660

Show key headers only | View raw


The My Documents directory is not guaranteed to be named "Documents". On
older versions of windows it was "My Documents", and on foreign versions
of windows it is a name in their language.

The correct way to get the path of this folder is, for example (couldn't
test since I'm on a mac right now)

import ctypes
from ctypes import wintypes

CSIDL_PERSONAL = 5

SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW
pszPath = ctypes.create_unicode_buffer(wintypes.MAX_PATH)
SHGetFolderPath.argtypes = [wintypes.HWND, ctypes.c_int,
wintypes.HANDLE, wintypes.DWORD, LPWSTR]
SHGetFolderPath.restype = wintypes.HRESULT

hResult = SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, pszPath)

if hResult == 0:
  print pszPath.value
else
  raise OSError("Could not find My Documents directory")


Linux systems generally provide their own way to get it (e.g.
xdg-user-dirs), on OSX everything I can find indicates it really is
always ~/Documents .

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Trouble getting to windows My Documents directory Mark Storkamp <mstorkamp@yahoo.com> - 2015-07-10 09:27 -0500
  Re: Trouble getting to windows My Documents directory Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-07-10 15:47 +0100
  Re: Trouble getting to windows My Documents directory Laura Creighton <lac@openend.se> - 2015-07-10 17:11 +0200
  Re: Trouble getting to windows My Documents directory MRAB <python@mrabarnett.plus.com> - 2015-07-10 16:12 +0100
    Re: Trouble getting to windows My Documents directory Mark Storkamp <mstorkamp@yahoo.com> - 2015-07-10 10:25 -0500
      Re: Trouble getting to windows My Documents directory Rustom Mody <rustompmody@gmail.com> - 2015-07-10 10:48 -0700
        Re: Trouble getting to windows My Documents directory Rustom Mody <rustompmody@gmail.com> - 2015-07-10 10:56 -0700
  Re: Trouble getting to windows My Documents directory Tim Chase <python.list@tim.thechases.com> - 2015-07-10 09:46 -0500
  Re: Trouble getting to windows My Documents directory random832@fastmail.us - 2015-07-10 20:24 -0400
  Re: Trouble getting to windows My Documents directory Chris Warrick <kwpolska@gmail.com> - 2015-07-11 09:28 +0200
  Re: Trouble getting to windows My Documents directory Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-07-11 11:47 -0400
  Re: Trouble getting to windows My Documents directory random832@fastmail.us - 2015-08-01 02:50 -0400

csiph-web