首页 > 其他 > 详细

文件下载

时间:2015-11-16 17:18:19      阅读:214      评论:0      收藏:0      [点我收藏+]

1.服务器文件下载到本地

//System.Net.WebClient c = new System.Net.WebClient();
//byte[] b = c.DownloadData(“server file path”);
//string content = Encoding.UTF32.GetString(b);
//File.WriteAllBytes("local file path", b); //转换问上传时的文件

2.本地文件另存为并 居中绘制文字

System.Drawing.Image fileimage = System.Drawing.Image.FromFile(“local file path”);
using (Graphics g = Graphics.FromImage(fileimage))
{
StringFormat stringFormat = new StringFormat();
stringFormat.LineAlignment = StringAlignment.Center;
stringFormat.Alignment = StringAlignment.Center;
System.Drawing.Rectangle lbRect = new System.Drawing.Rectangle(0, 0, fileimage.Width, fileimage.Height);
g.DrawString("asdfasdfasdf", new System.Drawing.Font("宋体", 50), Brushes.Black, lbRect, stringFormat);
g.Flush();
}
fileimage.Save(“new file path”);

3.文件上传

WebClient wc = new WebClient();
FileStream fs = new FileStream(“file path”, FileMode.Open, FileAccess.Read);
byte[] bt = new byte[fs.Length];
fs.Read(bt, 0, bt.Length);
wc.UploadData("new file path, "PUT", bt);

 

文件下载

原文:http://www.cnblogs.com/lqqqiaoqiao/p/4969394.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!