栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何以编程方式确定Dropbox文件夹的位置?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何以编程方式确定Dropbox文件夹的位置?

我在这里找到了答案。设置

s
等于第二行
~AppDataRoamingDropboxhost.db
,然后使用base64对其进行解码将给出路径。

def _get_appdata_path():    import ctypes    from ctypes import wintypes, windll    CSIDL_APPDATA = 26    _SHGetFolderPath = windll.shell32.SHGetFolderPathW    _SHGetFolderPath.argtypes = [wintypes.HWND,ctypes.c_int,wintypes.HANDLE,wintypes.DWORD,wintypes.LPCWSTR]    path_buf = wintypes.create_unipre_buffer(wintypes.MAX_PATH)    result = _SHGetFolderPath(0, CSIDL_APPDATA, 0, 0, path_buf)    return path_buf.valuedef dropbox_home():    from platform import system    import base64    import os.path    _system = system()    if _system in ('Windows', 'cli'):        host_db_path = os.path.join(_get_appdata_path(),   'Dropbox',   'host.db')    elif _system in ('Linux', 'Darwin'):        host_db_path = os.path.expanduser('~'         '/.dropbox'         '/host.db')    else:        raise RuntimeError('Unknown system={}'     .format(_system))    if not os.path.exists(host_db_path):        raise RuntimeError("Config path={} doesn't exists"     .format(host_db_path))    with open(host_db_path, 'r') as f:        data = f.read().split()    return base64.b64depre(data[1])


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/641398.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号