小编EKO*_*log的帖子

使用Ionic 3将文件保存到Downloads目录

我知道此链接:https : //cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#where-to-store-files

但我想将文件保存在下载目录中。是否可以使用Ionic将文件保存在任何路径中?如果是这样,请分享示例。

这是代码:

downloadImage(image) {

this.platform.ready().then(() => {

  const fileTransfer: TransferObject = this.transfer.create();

  const imageLocation = `${cordova.file.applicationDirectory}www/assets/img/${image}`;

  fileTransfer.download(imageLocation, cordova.file.externalDataDirectory + image).then((entry) => {

    const alertSuccess = this.alertCtrl.create({
      title: `Download Succeeded!`,
      subTitle: `${image} was successfully downloaded to: ${entry.toURL()}`,
      buttons: ['Ok']
    });

    alertSuccess.present();

  }, (error) => {

    const alertFailure = this.alertCtrl.create({
      title: `Download Failed!`,
      subTitle: `${image} was not successfully downloaded. Error code: ${error.code}`,
      buttons: ['Ok']
    });

    alertFailure.present();

  });

});

}
Run Code Online (Sandbox Code Playgroud)

基本上,我想将文件保存在用户可见的位置。

android cordova ionic-framework ionic3

6
推荐指数
2
解决办法
1万
查看次数

如何将 System.Windows.Forms 添加到我的 .NET 5.0 项目中?

对于我缺乏术语和理解,我提前表示歉意,我对 .NET 和 Visual Studio 非常陌生。

我在 Windows 7 64 位上的 Visual Studio Community 2019 版本 16.10.4 中使用 Visual Basic 为 .NET 5.0 制作控制台应用程序。

我正在尝试使用 Windows.Forms.Form 对象并弹出一个小窗口,并要求用户从列表框中选择一个项目。但到目前为止,我还没有成功地将 System.Windows.Forms 添加到我的项目中。

我尝试过Imports System.Windows.Forms,但给出了警告“导入‘System.Windows.Forms’中指定的命名空间或类型不包含任何公共成员或无法找到。”。

我转到“项目”->“添加 COM 引用”->“System_Windows_Forms”(版本 2.0)

该引用有一个警告:“无法为类型库 {215d64d2-031c-33c7-96e3-61794cd1ee61} 创建包装器程序集。类型库“System_Windows_Forms”已从 CLR 程序集导出,无法作为 CLR 程序集重新导入。 ”

我听说直接添加 .dll 可以解决这个问题,所以我删除了 COM 引用并转到“项目”->“添加项目引用”->“浏览”->“C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System”。 Windows.Forms.dll”

当我搜索 Forms.dll 时,我发现了大约 10 个文件,因此我只选择了看起来最正确的一个。之后,我可以在脚本中使用这些对象,并且 Visual Studio 可以自动完成对象的属性和功能。但是当我实际进入调试器并尝试运行脚本时,我收到错误:

System.IO.FileNotFoundException
HResult=0x80070002
Message=无法加载文件或程序集“System.Drawing.Common,Version=0.0.0.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”。该系统找不到指定的文件。
源 = System.Windows.Forms
StackTrace:
在 System.Windows.Forms.Control..ctor(Boolean autoInstallSyncContext)
在 System.Windows.Forms.Control..ctor()
在 System.Windows.Forms.ListControl..ctor()
在 System.Windows.Forms.ListBox..ctor()
在 GetNovel.Program.DetermineNovel()

这是导致错误的我的子程序:

Sub DetermineNovel() …
Run Code Online (Sandbox Code Playgroud)

.net vb.net visual-studio winforms

6
推荐指数
1
解决办法
8471
查看次数

C# sharepoint循环遍历文件夹和所有子文件夹中的所有文件

我试图在文件夹中的所有文件以及从第一个文件夹开始的所有子文件夹中循环。我找到了一种方法,但我认为这是愚蠢的,并且可能是一种更好的方法。

该代码循环遍历第一个文件夹和所有文件。之后,它再次循环子文件夹,然后循环文件,然后第三次循环。

我还有其他方法可以做到这一点吗?只需选择一个文件夹,它就会自动沿层次结构循环。

static void ReadAllSubs(string siteUrl, string siteFolderPath, string localTempLocation)
{
    ClientContext ctx = new ClientContext(siteUrl);
    ctx.AuthenticationMode = ClientAuthenticationMode.Default;
    SecureString passWord = new SecureString();
    string pwd = "xxx";
    foreach (char c in pwd.ToCharArray()) passWord.AppendChar(c);
    ctx.Credentials = new SharePointOnlineCredentials("test@test.com", passWord);
    FolderCollection folderCollection = ctx.Web.GetFolderByServerRelativeUrl("Delte%20dokumenter/07 - Detaljprosjekt").Folders;
    // Don't just load the folder collection, but the property on each folder too
    ctx.Load(folderCollection, fs => fs.Include(f => f.ListItemAllFields));
    // Actually fetch the data
    ctx.ExecuteQuery();

    foreach (Folder folder in folderCollection)
    {
        //LOOP MAIN …
Run Code Online (Sandbox Code Playgroud)

c# sharepoint

4
推荐指数
1
解决办法
5473
查看次数

在 Graph API 中使用组查询成员展开

我正在尝试构建一个查询,在其中传递 groupId 参数,并使用 C# 中的 GraphServiceClient 作为回报获取所有用户及其组成员身份。

我能够在一个查询中获取用户和组成员身份,并且能够在单独的查询中通过 groupId(但没有组成员身份)获取所有用户。但我无法将这两个查询合并为一个结果。是否可以?

这是我获取用户及其组成员身份的代码(使用带有 memberOf 的扩展):

var users = await _graphServiceClient.Users
                .Request()
                .Filter(graphFilter) // used for searching on givenName and surname
                .Select($"givenName,surname,mail,mobilePhone,id,userPrincipalName")
                .Expand(e => e.MemberOf)
                .GetAsync();
Run Code Online (Sandbox Code Playgroud)

这是我的代码,用于获取给定组中的用户:

var users = await _graphServiceClient
            .Groups[groupId] // Id of the group I want to get users from
            .Members
            .Request()
            .Select($"givenName,surname,mail,mobilePhone,id,userPrincipalName")
            //.Expand(e => e.MemberOf) // e is a DirectoryObject, so this does not compile.
            //.Expand(e => (e as Microsoft.Graph.User).MemberOf)
            //.Expand("memberOf")
            .GetAsync();
Run Code Online (Sandbox Code Playgroud)

有什么办法可以解决我的案子吗?我目前正在研究一种新方法,在从 /users 请求时是否可以在过滤器中使用 MemberOf,但我还不确定是否可能。

c# microsoft-graph-api graphserviceclient

1
推荐指数
1
解决办法
2492
查看次数

正则表达式-空格无法获取整数值

我正在尝试使用正则表达式获得模式匹配。如果消息在模式字符串后面有空格,则它会得到一个空字符串。

string str = "studentId: 1234, Name: Hello";
Regex reg = new Regex(@"studentId:(\d*)", RegexOptions.IgnoreCase);

Match m = reg.Match(str);
Group g = m.Groups[1];
int Id = int.Parse(g.ToString());
Run Code Online (Sandbox Code Playgroud)

学生号:1234(在职) 学生号:1234(不在职) 学生号:1234(不在职)

我需要获取值 1234,无论空格如何。

c# regex

0
推荐指数
1
解决办法
57
查看次数

如何在没有 if else 语句的情况下验证这些变量?

我对 C# 很陌生,所以请原谅我缺乏知识。我只是想检查以下内容:

  • “卡号长度”= 16
  • “卡 PIN 码长度”= 3
  • "CardNameHasSpace" 0 我不想使用 if else 语句,还有其他方法吗?

代码:

public bool Validate()
{
    CardNumberLength = Convert.ToString(GetCardNumber()).Length;

    CardPINLength = Convert.ToString(GetCardPIN()).Length;

    CardNameHasSpace = GetCardName().IndexOf(" ");
}
Run Code Online (Sandbox Code Playgroud)

c#

0
推荐指数
1
解决办法
212
查看次数