在C#中接收文件 [英] Receiving files in C#

查看:84
本文介绍了在C#中接收文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的问题:





让我们说我是HTTP服务器。



假设你是客户。



你要去给我发一个文件(例如图片)



我想把那个文件写到我的磁盘上



- 这就是问题所在。 1)我怎样才能从你那里得到这个文件2)希望我能把它写到磁盘上

解决方案

http://lmgtfy.com/?q=upload+files+C%23 [ ^ ]


 <   asp:FileUpload       runat   =  server    ID   =  fuDemo    /  >  
< asp:按钮 runat = server ID = btnUpload 文字 = 上传

onclick = btnUpload_Click / >
< asp:标签 runat = server ID = < span class =code-keyword> lblMessage 文本 = > < / asp:Label >





 受保护  void  btnUpload_Click( object  sender,EventArgs e)
{
// 将文件保存在C:\ TempLocation文件夹中。
fuDemo.SaveAs( @ C:\TempLocation \ + fuDemo.FileName);
lblMessage.Text = 文件已成功上传;
}


让我们假设你不知道如何谷歌,让我们假设你尝试但没有找到。让我们假设您不知道如何标记问题。



ASP.NET中的文件上传 [ ^ ]

C#中的文件上传 [ ^ ]



让我假设这会对你有所帮助。

Hi,

My problem:


Let's say that I am HTTP Server.

Let's say that You are the Client.

You are going to send me a file (eg. picture)

I want to write that file to my disk

- and here is the problem. 1) How can I get that file from you 2) Hopefully I can write it to disk

解决方案

http://lmgtfy.com/?q=upload+files+C%23[^]


<asp:FileUpload  runat="server" ID="fuDemo" />
<asp:Button  runat="server" ID="btnUpload" Text="Upload"

                onclick="btnUpload_Click" />
<asp:Label runat="server" ID="lblMessage" Text=""></asp:Label>



protected void btnUpload_Click(object sender, EventArgs e)
{
     // Save the file in C:\TempLocation folder.
     fuDemo.SaveAs(@"C:\TempLocation\" + fuDemo.FileName);
     lblMessage.Text = "File Successfully Uploaded";
}


Lets assume you don't know how to google, Let's assume you tried but didnt find. Lets assume you dont know how to tag Question here.

File Upload in ASP.NET[^]
File Upload in C#[^]

Let me assume this going to help you.


这篇关于在C#中接收文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆