Tag: C#的

在C#中复制一个目录的全部内容

我想在C#中将目录的全部内容从一个位置复制到另一个位置。 似乎没有办法做到这一点使用System.IO类没有很多递归。 在VB中有一个方法,如果我们添加一个对Microsoft.VisualBasic的引用,就可以使用它: new Microsoft.VisualBasic.Devices.Computer(). FileSystem.CopyDirectory( sourceFolder, outputFolder ); 这似乎是一个相当丑陋的黑客。 有没有更好的办法?

在C#中调用基础构造函数

如果我从一个基类继承,并希望从继承类的构造函数传递给基类的构造函数,我该怎么做? 例如, 如果我从Exception类继承我想要做这样的事情: class MyExceptionClass : Exception { public MyExceptionClass(string message, string extraInfo) { //This is where it's all falling apart base(message); } } 基本上我想要的是能够将字符串消息传递给基类Exception类。

为什么使用指针?

我知道这是一个非常基本的问题,但是我用一些基本的C ++编程开始编写一些高级语言的项目。 基本上我有三个问题: 为什么使用指针超过正常变量? 何时何地应该使用指针? 你如何使用指针与数组?

Typedef函数指针?

我正在学习如何动态加载DLL的,但我不明白的是这一行 typedef void (*FunctionFunc)(); 我有几个问题。 如果有人能回答他们,我将不胜感激。 为什么使用typedef ? 语法看起来很奇怪, 在void之后应该没有函数名或者什么的? 它看起来像一个匿名函数。 是否创建了一个函数指针来存储函数的内存地址? 所以我现在很困惑。 你能为我澄清一下吗?

确定两个矩形是否相互重叠?

我正在尝试编写一个C ++程序,该程序从用户处获取以下输入来构建矩形(2到5之间):高度,宽度,x-pos,y-pos。 所有这些矩形将平行于x和y轴存在,即它们的所有边将具有0或无穷大的斜率。 我试图实现这个问题中提到的东西,但我没有太多的运气。 我目前的实施做了以下工作: // Gets all the vertices for Rectangle 1 and stores them in an array -> arrRect1 // point 1 x: arrRect1[0], point 1 y: arrRect1[1] and so on… // Gets all the vertices for Rectangle 2 and stores them in an array -> arrRect2 // rotated edge of point a, […]

在Docker中运行一个基本的Qt应用程序

我试图在Docker for Windows中运行一个基本的控制台应用程序( 用Qt开发 )。 开发环境是windows 10,编译器VC2015,32位应用程序。 在我尝试移植实际的应用程序之前,这是个好世界,想法是找到问题。 代码是最简单的c ++代码: #include <QCoreApplication> #include <iostream> using namespace std; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); std::cout<<"Hello world"; return a.exec(); } Dockerfile是: # Comment: #It needs a Microsoft environment to run FROM microsoft/nanoserver:latest #Create a folder inside the home folder in the Container Operating System […]

运行Docker镜像会导致Kestrel异常

当我尝试在Linux操作系统中运行我的Docker镜像时,我正面临奇怪的行为 – 图像包含.Net核心Web API项目 这是我的Program.cs var host = new WebHostBuilder() .UseKestrel().UseStartup<Startup>().Build(); host.Run(); 我的Docker-compose.yml文件 version: '2' services: server: image: repo.testCompany.com:1443/testCompany:6 ports: – "60000:60000" hostname: ucp.${HOST_HOSTNAME} restart: unless-stopped 图像被构建并推送成功。当Web API尝试运行容器内的项目并引发运行时异常时,问题就出现了 – Unhandled Exception: System.AggregateException: One or more errors occurred. (Error -99 EADDRNOTAVAIL address not available) —> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -99 EADDRNOTAVAIL address not available at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode) at […]