我正在寻找一种方法来从本地计算机的所有用户(每个用户)获取“我的文档”文件夹的路径。我找到了几篇文章,但它们展示了如何为当前用户执行此操作。
我使用SHGetKnownFolderPath测试了下面的代码,但它仅适用于登录用户。在接收 WindowsIdentity 对象的类构造函数中,我使用其他用户的令牌创建它,但返回的路径是登录用户的路径。
有谁知道我如何获取文件夹路径?
谢谢。
using Syroot.Windows.IO;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ConsoleApplication2
{
class Program
{
private static Dictionary<KnownFolderType, KnownFolder> _knownFolderInstances;
static void Main(string[] args)
{
KnownFolderType type = KnownFolderType.Documents;
KnownFolder knownFolder = new KnownFolder(type);
//Ctor with WindowsIdentity parameter
//public KnownFolder(KnownFolderType type, WindowsIdentity identity)
//{
// Type = type;
// Identity = identity;
//}
// Write down the current and default path.
Console.WriteLine(knownFolder.Type.ToString());
try
{
Console.Write("Current Path: ");
Console.WriteLine(knownFolder.Path);
Console.Write("Default Path: ");
Console.WriteLine(knownFolder.DefaultPath); …Run Code Online (Sandbox Code Playgroud) 我正在使用可扩展包(https://pub.dev/packages/expandable),当我在点击复选框时调用 setState () 方法时,可扩展面板会在小部件树重建期间关闭。
当我调用 setState () 时,我告诉控制器保持面板展开expController.expanded = true,但这不起作用。
我研究过,在我看来,解决方案是使用密钥,但我的测试不起作用。
有人能帮我吗?我需要更改复选框的状态,但保持面板展开。这是我的代码的示例:
class ExpandableCard extends StatefulWidget {
ExpandableCard({Key key}) : super(key: key);
@override
_ExpandableCardState createState() => _ExpandableCardState();
}
class _ExpandableCardState extends State<ExpandableCard> {
var _value = false;
@override
Widget build(BuildContext context) {
ExpandableController expController =
new ExpandableController(initialExpanded: false);
return ExpandableNotifier(
controller: expController,
child: Padding(
padding: const EdgeInsets.all(2),
child: Card(
clipBehavior: Clip.antiAlias,
child: Column(
children: <Widget>[
ScrollOnExpand(
scrollOnExpand: true,
scrollOnCollapse: false,
child: ExpandablePanel(
theme: const …Run Code Online (Sandbox Code Playgroud)