为什么当我给路径"c:"时,它直接将我改为应用程序文件夹?
static void Main(string[] args)
{
DirectoryInfo dir = new DirectoryInfo("c:");
Console.WriteLine(dir.FullName);
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
输出如下:
c:\ users ...\documents\visual studio 2010\projects\consoleApplication9\bin\debug
但是当我把@"c:\"它放到磁盘上时c:
尽管如此"d:"并将@"d:\"其带到磁盘上d:.
所以我需要一种让"c:"磁盘转发的方法c:
提前致谢!
我有一个listView和两个按钮(向上,向下),我想向上或向下移动所选项目.
我已经考虑过在所选项目和上层项目之间进行交换..但是我尝试的代码......没有意义,因为索引是只读的.
也是地雷或总和不欠人.我根本不能搞乱指数.
private void btnDown_Click(object sender, EventArgs e)
{
listView1.SelectedItems[0].Index--; // It's ReadOnly.
}
Run Code Online (Sandbox Code Playgroud)
那么..我如何让用户能够改变ListViewItem索引,就像VB让我们改变这些项目索引一样[如图中所示]

提前致谢 ...
我一直在阅读有关如何检查 LAN 上特定端口上的所有侦听服务器的信息,最后我编写了一些代码,它可以按我想要的方式工作。
我正在使用 System.Threading.Tasks.Parallel 尽快连接到所有 254 个 IP 地址,例如
:192.168.1。1 - 192.168.1。第254章
我需要的是为这些连接尝试设置超时,因为失败时需要大约 15-20 秒才能打印:“连接失败”..那么我该怎么做?
这是客户端代码:
static void Main(string[] args)
{
Console.WriteLine("Connecting to IP addresses has started. \n");
Parallel.For(1, 255, i =>
{
Connect("192.168.1." + i);
});
Console.ReadLine();
}
private static void Connect(string ipAdd)
{
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
SocketAsyncEventArgs e = new SocketAsyncEventArgs();
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse(ipAdd), 9990);
e.RemoteEndPoint = ipEnd;
e.UserToken = s;
e.Completed += new EventHandler<SocketAsyncEventArgs>(e_Completed);
Console.WriteLine("Trying to connect …Run Code Online (Sandbox Code Playgroud) 我有一个文件传输应用程序,可以发送文件和文件夹.(服务器 - 客户端)
我试图通过TCP(套接字)发送数据,我已经为传输数据的方式做了一些规则,所以如果它发送一个包含许多文件的大文件夹,它应该将它们压缩成一个zip文件首先然后当该zip文件发送时,接收器必须解压缩它.所以我决定使用SharpZibLib,我对此有疑问.

PS:
首先是时间优先,使用SharpZipLib的目的是将(太多文件)放在一个文件中,这样发送的速度比发送(太多文件)的速度快一个.
这里有更多细节.
我想保存一个有两个选项(.Png或.Jpeg)的图像,所以我只需要显示Png和Jpeg格式的文件,比如当我们选择Save type as All Images时它会在对话框中显示所有类型的图像.那我该怎么办呢?
using(SaveFileDialog saveFileDialog1 = new SaveFileDialog())
{
saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyPictures);
saveFileDialog1.Filter = "Images (*.Png + Jpeg)|*.Png + *.Jpeg";
}
Run Code Online (Sandbox Code Playgroud) 我是Angular2的新手,直到现在我都成功编写了5 Min Quickstart。
我想学习如何在Angular2和Dart中使用路由,不幸的是,我还没有在网络上找到任何示例。大多数文章都在谈论使用Typescript进行路由,但我无法让它与dart一起使用。
我正在将Webstorm与dart插件一起使用。
import 'dart:html';
import 'package:angular2/angular2.dart';
import 'package:angular2/bootstrap.dart';
import 'package:angular2/router.dart';
@Component(selector: 'my-app', template: '<h1>My First Angular 2 App</h1>')
class AppComponent {}
void main() {
bootstrap(AppComponent);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在gh-pages上部署我的项目站点,它是带有webpack的angular2应用程序,我将基本URL设置为我的repo名称,除了模板中的相对路径外,一切都正常加载,这就是我的意思
import {Component} from '@angular/core';
@Component({
selector: 'header',
template: `
<img class="fb-logo" [src]="fbLogo"/>
<img class="ang-logo" [src]="angularLogo"/>
`
})
export class Header{
angularLogo = '../../assets/img/angular-logo.png';
fbLogo = '../../assets/img/share/facebook.svg';
}
Run Code Online (Sandbox Code Playgroud)
这适用于本地开发,但是当我将它推送到gh-pages分支时它给出了404,因为它试图从根服务器获取它http://myAcc.github.io/assets/img/fbLogo.svg而不是http://myAcc.github.io/myRepo/assets/img/fbLogo.svg
我无法弄清楚如何修复它,所以我尝试使用它作为inline-svg使用 require
angularLogo = require('../../assets/img/angular-logo.png');
fbLogo = require('../../assets/img/share/facebook.svg');
Run Code Online (Sandbox Code Playgroud)
它在本地(使用xss警告)工作正常,但当我部署到gh-pages它时它拒绝运行https.
我该如何解决这个问题?
我有一个简单的游戏,我试图找到两点之间的最短路线
该地图由二维数组组成matrix: Node[][],
class Node{
index: {
x: number,
y: number
},
isAvailable: boolean
}
Run Code Online (Sandbox Code Playgroud)
该算法应返回关于节点可用性的最短路径。
例如,树被标记为不可用node.isAvailable = false
我一直致力于实现这个矩阵的算法
我尝试从这里使用Dijkstras算法,但我不知道如何应用它,我做到了
const graph = new Dijkstra();
//convert the matrix (2d array) to graph
matrix.map((row) => {
row.map((node: Node) => {
let x = node.index.x;
let y = node.index.y;
graph.addVertex(x + ":" + y, {x: x, y: y});
});
});
console.log(graph.shortestPath('0:0', '5:5'));
//the output was ['0:0'] (definitly not the answer)
Run Code Online (Sandbox Code Playgroud)
如何将该算法应用于该矩阵?
PS这是我的完整代码
我可以使用out递归方法的参数吗?如果可能,我如何使用以下代码执行此操作?
private void PrepareDir(out List<_File> listFiles,string root,string dirPath) {
DirectoryInfo dirRoot = new DirectoryInfo(dirPath);
FileInfo [] Files = dirRoot.GetFiles();
dirPath = dirPath.Substring(root.Length);
foreach (FileInfo file in Files) {
_File _file = new _File();
_file.Name = dirPath + "\\" + file.Name;
_file.Path = file.FullName;
_file.Size = file.Length;
listFiles.Add(_file);
}
foreach (DirectoryInfo dir in dirRoot.GetDirectories()) {
PrepareDir(out listFiles, root, dir.FullName);
}
}
private void btnButton1_Click(object sender, EventArgs e) {
List<_File> Files = new List<_File>();
PrepareDir(out Files,currAddress, currAddress);
}
Run Code Online (Sandbox Code Playgroud) 我试图从WCF服务获取一个Image
我有一个OperationContract函数,它返回一个Image到客户端,
但是当我从客户端调用它时,我得到这个异常: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9619978'.
客户:
private void btnNew_Click(object sender, EventArgs e)
{
picBox.Picture = client.GetScreenShot();
}
Run Code Online (Sandbox Code Playgroud)
Service.cs:
public Image GetScreenShot()
{
Rectangle bounds = Screen.GetBounds(Point.Empty);
using (Bitmap bmp = new Bitmap(bounds.Width,bounds.Height))
{
using (Graphics g = Graphics.FromImage(bmp))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
using (MemoryStream ms …Run Code Online (Sandbox Code Playgroud) c# ×7
angular ×2
angular-dart ×1
compression ×1
dart ×1
github-pages ×1
image ×1
listview ×1
path ×1
recursion ×1
search ×1
sharpziplib ×1
sockets ×1
typescript ×1
wcf ×1
winforms ×1