有人可以给我一些帮助,使用语法为语言构建一个ocaml解释器:
Prog ::= Def* Expr
Def ::= id id* = Expr
Expr ::= int | id | Expr '+' Expr | Expr '*' Expr | id Expr* | if Expr then Expr else Expr
Run Code Online (Sandbox Code Playgroud)
到目前为止我这样做了:
type expr = I of int
| Id of string
| Add of expr * expr
| Multiply of expr * expr
| If of expr * expr * expr
let rec evaluate = function
| I n -> n
| Add(e1,e2) -> evaluate e1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个上传/下载.exe文件的程序FTP
我尝试过使用FtpWebRequest,但我只能成功上传和下载.txt文件.
然后我在这里找到了一个下载解决方案WebClient:
WebClient request = new WebClient();
request.Credentials = new NetworkCredential("username", "password");
byte[] fileData = request.DownloadData("ftp://myFTP.net/");
FileStream file = File.Create(destinatie);
file.Write(fileData, 0, fileData.Length);
file.Close();
Run Code Online (Sandbox Code Playgroud)
此解决方案有效.但我看到WebClient有一种方法DownloadFile没有奏效.我想是因为它不工作FTP只HTTP.我的假设是真的吗?如果不是,我怎么能让它工作?
有没有其他解决方案上传/下载.exe文件到ftp使用FtpWebRequest?
如何添加到foreach循环中的数组.
伪示例
String[] mylist;
foreach ( ipadress ip in list )
{
i want to add to array ip.ToString();
}
then put my list to a textbox
Run Code Online (Sandbox Code Playgroud) 我试图通过TCP将文件从服务器发送到客户端.
服务器端代码,发送文件:
NetworkStream netStream = client.GetStream();
FileStream fs = new FileStream("usb.exe",FileMode.Open, FileAccess.Read);
byte[] data = new byte[fs.Length];
fs.Read(data,0, data.Length);
fs.Flush();
fs.Close();
netStream.Write(data, 0, data.Length);
netStream.Flush();
Run Code Online (Sandbox Code Playgroud)
客户端代码,接收文件:
FileStream str = new FileStream("usb.exe", FileMode.Create, FileAccess.Write);
byte[] data = new byte[1024];
while ((dataCitit = netStream.Read(data,0, data.Length)) > 0)
{
Thread.Sleep(25);
Application.DoEvents();
str.Write(data, 0, dataCitit);
totalbytes += dataCitit;
}
str.Close();
Run Code Online (Sandbox Code Playgroud)
有人能指出我弄错了吗?
该文件有1036 kb,它只发送1032 kb然后卡住它不会在客户端输出while循环.
此外,如果我关闭服务器并快速打开它,它会发送最后一个字节,文件完全发送.(此文件打开完美)
我认为这是服务器端的问题,不是发送所有字节,而是为什么以及在哪里......