小编jLy*_*ynx的帖子

res.sendFile不是Node.js函数

我无法使用node.js发送HTML文件

所以首先这是我得到的错误

Application has thrown an uncaught exception and is terminated:
TypeError: res.sendFile is not a function
    at Server.<anonymous> (C:\Program Files\iisnode\www\test\app.js:4:6)
    at emitTwo (events.js:88:13)
    at Server.emit (events.js:173:7)
    at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:529:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:89:23)
Run Code Online (Sandbox Code Playgroud)

我的app.js代码是

var http = require('http');

http.createServer(function (req, res) {
    res.sendFile('test.html', { root: __dirname });
}).listen(process.env.PORT);  
Run Code Online (Sandbox Code Playgroud)

如果我遗漏了一些简单的东西,我很抱歉,因为这是我制作的第一个node.js程序

javascript iis node.js

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

在控制台窗口关闭时阻止程序关闭

所以发生了什么是我的控制台程序打开然后从文本文件运行外部c#程序/代码.这一切都运行良好,但当我关闭原始窗体窗口时,它执行的程序/代码也关闭.有没有办法阻止我从关闭运行的文本文件代码?

这是它调用运行程序的代码

static void MemExe(byte[] buffer)
        {
            Assembly asm = Assembly.Load(buffer);

            if (asm.EntryPoint == null)
                throw new ApplicationException("No entry point found!");

            MethodInfo ePoint = asm.EntryPoint;
            ePoint.Invoke(null, null);
        }
Run Code Online (Sandbox Code Playgroud)

其中缓冲区是以字节为单位的代码/程序

这是我的主要

static void Main(string[] args)
        {
            var data = File.ReadAllText(@"program.txt");
            MemExe(data);
        }
Run Code Online (Sandbox Code Playgroud)

c#

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

使用CefSharp C#将POST数据发送到URL

我试图找出如何使用cefsharp将帖子数据直接发送到网址.以下是我要发送的示例:

var values = new Dictionary<string, string>
{
     { "thing1", "hello" },
     { "thing2", "world" }
};
FormUrlEncodedContent content = new FormUrlEncodedContent(values);
Run Code Online (Sandbox Code Playgroud)

这将创建thing1=hello&thing2=world 我想http://example.com/mydata.php使用现有的cefsharp浏览器将此POST数据发送到URL .

从我所看到的

browser.Load("http://example.com/mydata.php");
Run Code Online (Sandbox Code Playgroud)

无法附加POST数据,有没有办法可以做到这一点?

基本上我需要保留浏览器已经拥有的相同的cookie,所以如果有另一种方法可以做到这一点,例如使用HttpWebRequest和cefsharp ChromiumWebBrowser cookie然后在该请求之后再次同步它们,那也可以,但我不是确定是否可行.

c# cefsharp

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

Galaxy Watch无法连接到Tizen Studio

因此,我制作了第一个应用程序,它在模拟器上运行良好,但是现在我想将其部署到我的物理设备上。

我已启用蓝牙并将手表的WiFi连接到与计算机相同的WiFi接入点。我还启用了调试。但是每次我尝试连接时都会收到此错误消息。如果我在Tizen studio中按了“扫描”按钮,则找不到任何内容,如果我直接指定IP,则它将无法连接。

我已经在3个不同的WiFi接入点上进行了尝试。我还允许通过本地防火墙的TCP和UDP端口26101。

在此处输入图片说明

我不确定为什么这行不通。我缺少某处的设置吗?

谢谢

tizen samsung-galaxy-gear samsung-galaxy

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

SDB 设备未经授权

您好,我最近一直在为我的三星 Galaxy 智能手表开发应用程序。最初当我连接到它时,它请求许可。但不久前我重置了我的设备(以启用三星支付)。然后我进行预编码以恢复备份。

现在,当我尝试使用 sdb 将手表连接到计算机时,收到错误消息

C:\tizen-studio\tools>sdb connect 192.168.137.41:26101
connecting to 192.168.137.41:26101 ... device unauthorized. Please approve on your device.
Run Code Online (Sandbox Code Playgroud)

但我的设备上什么也没有显示。

然后,当我再次运行该命令时,我收到消息

C:\tizen-studio\tools>sdb connect 192.168.137.41:26101
192.168.137.41:26101 is already connected
Run Code Online (Sandbox Code Playgroud)

因此,我尝试像过去一样获得 shell 访问权限,然后出现以下错误:

C:\tizen-studio\tools>sdb shell
device unauthorized. Please check the confirmation dialog on your device.
device unauthorized. Please check the confirmation dialog on your device.
device unauthorized. Please check the confirmation dialog on your device.
Run Code Online (Sandbox Code Playgroud)

但同样,我的手表上没有显示任何对话框。

所以现在,我无法为我的手表开发更多应用程序,因为它不再让我连接到它。

要在 Android 设备上解决此问题,通常只需撤销 USB 调试授权即可。但我在 Tizen 操作系统上找不到这个选项。

我该怎么做才能让我的手表再次连接到我的电脑?

tizen samsung-galaxy-gear

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

UIView不会以编程方式移动

因此我必须有一些简单的东西,因为我无法弄清楚如何移动我的UIView

这就是我到目前为止所拥有的

我的.m文件

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self buttonLayout];
}

-(void)buttonLayout
{
     UIView *theView = [self buttonGroup];
     theView.center=CGPointMake(50, 50);
}
Run Code Online (Sandbox Code Playgroud)

我的.h文件

@property (nonatomic, retain) IBOutlet UIView *buttonGroup;
Run Code Online (Sandbox Code Playgroud)

所以这就是我到目前为止,我只是似乎无法让它移动到所有PS我不希望它动画,因为我让我的布局移动,以弥补不同的iPhone屏幕尺寸:)

objective-c ios

2
推荐指数
2
解决办法
5058
查看次数

将位图设置为MP3的封面

我一直试图将位图设置为MP3的封面艺术,但我似乎无法让它工作.它没有抛出任何错误,但是当我播放MP3时,位图没有显示.

这就是我目前拥有的:

TagLib.File f = TagLib.File.Create("song.mp3");

Image currentImage = getAlbumArt(result.passedAlbumID);
Picture pic = new Picture();
pic.Type = PictureType.FrontCover;
pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
pic.Description = "Cover";
MemoryStream ms = new MemoryStream();
currentImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Position = 0;
pic.Data = ByteVector.FromStream(ms);
f.Tag.Pictures = new IPicture[1] { pic };
pictureBox1.Image = currentImage; //testing the image is correct

f.Save();
ms.Close();
Run Code Online (Sandbox Code Playgroud)

c# bitmap taglib-sharp

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

在GSM调制解调器上使用什么字符集

我有2个GSM调制解调器,K3772-Z的字符集为8859-1,工作正常.

但对于我的其他GSM调制解调器,它的中兴K3565-Z,它不会工作它继续返回"无法设置字符集"

在此输入图像描述

有谁知道你的字符集是什么,或者有没有办法让我找出使用什么字符集?

c# gsm at-command

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

获取结构数组c ++中的元素数

我需要找到结构数组中的元素数

我有这个结构

struct Features {
    int feature1;
    string feature2;
    string feature3;
    string feature4;
    bool feature5;
};
Run Code Online (Sandbox Code Playgroud)

然后我把它变成了一个数组

Features *feature = new Features[100];
Run Code Online (Sandbox Code Playgroud)

然后我输入了一些值

for(int i = 0; i < 3; i++)
{
    feature[i].feature1 = 5;
    feature[i].feature2 = "test";
    feature[i].feature3 = "test2";
    feature[i].feature4 = "test3";
    feature[i].feature5 = true;
}
Run Code Online (Sandbox Code Playgroud)

现在我想获取数组的大小,应该是 3 (2)

我该怎么做呢?

cout << (sizeof feature / sizeof *feature) << endl;
Run Code Online (Sandbox Code Playgroud)

似乎不起作用,因为它打印了不正确的值。(它继续打印 4)

对不起,如果这是一个愚蠢的问题,我还在学习 C++

c++ arrays struct

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

StreamReader对于大文件来说非常慢

我想读一个文件,在这种情况下是3mb,这需要大约50-60秒,这似乎非常慢.有谁知道如何让这更快?

string text = null;
using (StreamReader sr = new StreamReader(file, Encoding.Default))
{
    string line;
    while ((line = sr.ReadLine()) != null)
    {
        text += (line);
        backgroundWorker1.ReportProgress(text.Length);
    }
}
Run Code Online (Sandbox Code Playgroud)

我还需要使用后台工作程序,以便我可以报告已加载的百分比(对于大约500mb到1gb的文件)

c# streamreader

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