2016-10-13 43 views

回答

3

這Dropbox的幫助頁面告訴我們哪裏該信息存儲,即在一個JSON文件在用戶的應用程序數據:https://www.powershellgallery.com/packages/Spizzi.Profile/1.0.0/Content/Functions%5CProfile%5CInstall-ProfileEnvironment.ps1 需要注意的是它不:https://www.dropbox.com/help/4584

function GetDropBoxPathFromInfoJson 
{ 
    $DropboxPath = Get-Content "$ENV:LOCALAPPDATA\Dropbox\info.json" -ErrorAction Stop | ConvertFrom-Json | % 'personal' | % 'path' 
    return $DropboxPath 
} 

上面的線是從取不要檢查您是否有Dropbox商家帳戶,或者您是否擁有這兩個帳戶。它只是使用個人的。

然後你可以使用這個基地的Dropbox文件夾建立你的最終路徑,例如:

$targetPath = Join-Path -Path (GetDropBoxPathFromInfoJson) -ChildPath 'RootDropboxFolder\Subfolder1\Subfolder2' 
if (-not (Test-Path -Path $targetPath)) { throw "Path '$targetPath' not found!" } 

-

使用host.db文件

替代方式,如圖此頁上: http://bradinscoe.tumblr.com/post/75819881755/get-dropbox-path-in-powershell

$base64path = gc $env:appdata\Dropbox\host.db | select -index 1 # -index 1 is the 2nd line in the file 
$dropboxPath = [System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($base64path)) # convert from base64 to ascii 
相關問題