Tag: 文件传输

在C#中通过网络发送大文件的好方法?

我正在尝试构建一个可以从网络中另一台机器上运行的服务请求文件的应用程序。 这些文件可能相当大(有时500mb +)。 我正在考虑通过TCP发送它,但我担心它可能需要将整个文件存储在内存中。 可能只有一个客户。 也不接受复制到共享目录。 唯一需要的通信是客户端说“gimme xyz”和发送它的服务器(以及确保正确发生这种情况所需的一切)。 有什么建议?

IE中的文件下载因https失败而失败

我正在尝试通过HTTPS下载文件,但它在IE中失败但与Firefox和Chrome完美配合: aspx代码如下: 按钮单击代码背后的代码如下: protected void Button1_Click(object sender, EventArgs e) { string filename = TextBox1.Text; string filepath = Server.MapPath(filename); byte[] bytFile = null; FileStream fs = new FileStream(filepath, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(filepath).Length; bytFile = br.ReadBytes((int)numBytes); string extension = “.xlsx”; Response.ClearHeaders(); Response.Clear(); Response.Buffer = true; if (extension == “.doc”) […]

Stream.CopyTo – 如何获取发送的字节?

我尝试在ftp-upload上获得传输速度,但我不知道应该“获取”它: 代码片段: FtpWebRequest request = (FtpWebRequest)WebRequest.Create(job.GetDestinationFolder() + “\\” + fileOnlyName); request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(Manager._user, Manager._password); using (var requestStream = request.GetRequestStream()) { using (var input = File.OpenRead(file)) { //input.CopyToAsync() input.CopyTo(requestStream); //IS HERE ANY METHOD OR ATTRIBUTE, WHICH SHOWS THE SENT BYTES ? } } FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Console.WriteLine(“Upload File Complete, status {0}”, […]

从c sharp客户端应用程序上传到PHP服务器

目前我有一个尖锐的应用程序(客户端应用程序) 和一个写PHP的Web应用程序。 我想在客户端执行特定操作时传输一些文件。 这是将文件上传到php服务器的客户端代码.. private void button1_Click(object sender, EventArgs e) { System.Net.WebClient Client = new System.Net.WebClient(); Client.Headers.Add(“Content-Type”, “binary/octet-stream”); byte[] result = Client.UploadFile(“http://localhost/project1/upload.php”, “POST”, @”C:\test\a.jpg”); string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); } 这是用于移动文件的upload.php文件.. $uploads_dir = ‘./files/’; //Directory to save the file that comes from client application. foreach ($_FILES[“pictures”][“error”] as $key => $error) { if ($error == […]

从C#访问远程目录

我试图从asp.net中的C#程序访问远程网络共享。 我需要的是类似的东西 function download(dirname) { directory = (This is the part I don’t know how to do) for dir in directory: download(dir); for file in directory: copyfile(file); } 我的问题是该目录需要用户名和密码才能访问,我不知道如何提供它们。 谢谢你尽你所能的帮助。