标签: external

如何在 WPF 中使用外部配置文件?

我想设置一个外部配置文件,我可以将它存储在我的 WPF 应用程序的目录中,也不一定是我创建程序时的 exe 目录。

我创建了一个 App.Config 文件并将 System.Configuration 添加到我的程序集中。我的 App.Config 有:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings file="sd.config">
   <add key="username" value="joesmith" />
  </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我的 sd.config(外部文件)现在在我的项目的根目录中,有

<?xml version="1.0"?>
 <appSettings>
   <add key="username1" value="janedoe" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)

在我使用的 MainWindow cs 类中

string username = ConfigurationManager.AppSettings.Get("username1");
Run Code Online (Sandbox Code Playgroud)

它返回一个空字符串。当我刚刚从 App.Config 检索用户名字段时,它可以工作。我错过了什么?非常感谢!

wpf configuration external

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

刷新外部加载的 javascript 文件

我将许多 js 文件放在另一个文件夹中,以便于更新和在不同页面之间共享。这些文件是从另一个页面调用的,我使用

<script type="text/javascript" src="/js/file.js"></script>
Run Code Online (Sandbox Code Playgroud)

符号。

这工作正常,但是当我在这些 js 文件之一中更改某些内容时,浏览器(chrome、firefox、safari)仍然加载以前的版本而不进行更改,因此不会将它使用的 js 文件更新为更新的文件。我试图清除缓存以强制它再次加载 js 文件(带有更改),但无济于事。

我唯一的解决方法是将外部文件重命名为 file2.js 并将其包含在调用它的页面中,但这是一个乏味的过程,因为如果我进行另一次更改,我必须将名称更改为 file3.js 等。

有没有办法强制浏览器重新加载原始js而不使用以前存储的js>

javascript external

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

外部 Js 文件无法运行 Jquery

我的外部 js 文件(example.js):

alert("External js file has just been loaded !");

$("#start").click(function (e) {
    alert("Starting !");  
});
Run Code Online (Sandbox Code Playgroud)

我的 HTML 文件有<script type="text/javascript" src="example.js"></script>. 当我加载页面时,它发出警报"External js file has just been loaded !",这意味着 js 文件已成功加载。

但是,当我单击“开始”按钮时,它不会发出 alert "Starting !"

当我将 example.js 文件的内容插入到 html 文件时,它会发出警报"Starting !"

<script>
    alert("External js file has just been loaded !");

    $("#start").click(function (e) {
        alert("Starting !");  
    });
</script>
Run Code Online (Sandbox Code Playgroud)

如何解决外部 js 文件的此类问题?

html javascript jquery external

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

如何在 UWP 中运行 PowerShell 命令?

如何在 UWP 中运行 PowerShell 命令?

using (PowerShell PowerShellInstance = PowerShell.Create())
{
    PowerShellInstance.AddCommand(".\fpcalc.exe " + file.Path + " > out.txt");
}
Run Code Online (Sandbox Code Playgroud)

powershell external sandbox uwp

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

如何从两个单独的页面将PHP变量传递给Javascript变量?

我试图将PHP变量传递给Javascript变量,例如:

<?php   $myvar=10;   ?>

<script type="text/javascript">
    jsvar = <?php echo $myvar; ?>;
    document.write(jsvar);
</script>
Run Code Online (Sandbox Code Playgroud)

如何在另一页上分离变量?例如,Page1.html会有document.write,变量将从page2.php中提取

javascript php variables external

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

如何使用C中的.h文件从外部.c文件中调用函数?

我在调用外部.c文件中定义的外部函数时遇到了一些麻烦.

我的主文件(main.c)是:

#include <stdio.h>
#include "header.h"

int main () {

int a = 100;
int b = 200;
int ret;

ret = maximo(a, b);

printf( "Max value is : %d\n", ret );

return 0;
}
Run Code Online (Sandbox Code Playgroud)

我使用一个.h名为header.h声明函数的文件maximo().该header.h文件是:

int maximo(int num1, int num2);
Run Code Online (Sandbox Code Playgroud)

在另一个.c文件中,我有功能的定义maximo().该maximo.c文件是:

int maximo(int num1, int num2) {

int result;

if (num1 > num2)
   result = num1;
else
   result = num2;

return …
Run Code Online (Sandbox Code Playgroud)

c file external function call

-2
推荐指数
1
解决办法
151
查看次数

将此C代码移植到Delphi/Lazarus

我在C中有这个代码,我想移植到Delphi,但我不能让它工作.

.CPP代码

#include <Windows.h>

#include <io.h>
#include <stdio.h>

#include "GLibExp.h"
#pragma comment(lib, "GLib.lib")

void MyCFunc(LPCTSTR GStr)
{
    GFile GVar = NULL;
    GVar = GrfLoad(GStr, 1);
    if ( !GVar )
    {
        printf("Error during loading!\n");
    } else
        printf("All fine!\n");

    GrfFree(GVar);
    system("pause");
}

void main()
{
    CHAR StrG[MAX_PATH] = "Test.grf";
    MyCFunc(StrG);
    return;
}
Run Code Online (Sandbox Code Playgroud)

GLibExp.h

#ifndef GLibExpH
#define GLibExpH

#if defined(GRF_DLL)
#define GEXPORT __declspec(dllexport)
#else
#define GEXPORT extern
#endif

class CGFILE;
typedef CGFILE* GFile;
//typedef void* GFile; //Also works like this

#ifdef __cplusplus
extern …
Run Code Online (Sandbox Code Playgroud)

delphi dll external lazarus lib

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

标签 统计

external ×7

javascript ×3

c ×1

call ×1

configuration ×1

delphi ×1

dll ×1

file ×1

function ×1

html ×1

jquery ×1

lazarus ×1

lib ×1

php ×1

powershell ×1

sandbox ×1

uwp ×1

variables ×1

wpf ×1