1
打開OneDrive文件當我嘗試從一個WPF應用程序,我得到以下錯誤打開OneDrive文件路徑中使用File.ReadAllText(filename);
時:如何從WPF應用程序
The file cannot be accessed by the system.
儘管試圖檢查讀取權限明確:
private static bool HasReadPermissions(string filename)
{
FileSystemSecurity security = File.GetAccessControl(filename);
var rules = security.GetAccessRules(true, true, typeof(NTAccount));
var currentUser = new WindowsPrincipal(WindowsIdentity.GetCurrent());
foreach (FileSystemAccessRule rule in rules)
{
if (!currentUser.IsInRole(rule.IdentityReference.Value) || (rule.FileSystemRights & (FileSystemRights.ReadData | FileSystemRights.Read)) == 0)
{
continue;
}
if (rule.AccessControlType == AccessControlType.Deny)
{
return false;
}
if (rule.AccessControlType == AccessControlType.Allow)
{
return true;
}
}
return false;
}
有沒有什麼辦法來檢查OneDrive權限或檢測文件是否是OneDrive文件或實際在WPF應用程序中打開OneDrive文件?我認爲這個文件在線提供的事實可能是問題;有沒有辦法在WPF或Windows桌面應用程序中檢測僅在線文件?
這有幫助嗎?http://blogs.msdn.com/b/dotnet/archive/2013/11/25/opening-files-from-skydrive-using-net.aspx – 2014-11-06 06:12:52
您能否提供一個示例路徑? – 2015-02-18 03:57:21