读取文件夹下的文件

public string ReadImagesPaths()
{
string result = string.Empty;
try
{
string path = System.IO.Directory.GetCurrentDirectory();
DirectoryInfo files = new DirectoryInfo(path+@"\Images");
FileInfo[] fileinfo = files.GetFiles();
foreach (FileInfo file in fileinfo)
{
//result += files +@"\"+ file.Name + ";";
result += file.Name + ";";
}
}
catch(Exception ex)
{
_log.Error(ex);
}
return result;
}

根据文件名下载图片并另存为:

public Stream DownloadImage(string name)
{
string path = System.IO.Directory.GetCurrentDirectory();
DirectoryInfo files = new DirectoryInfo(path + @"\Images");
FileInfo[] fileinfo = files.GetFiles();
FileStream filecontent;
Byte[] filebyte = new Byte[];
foreach (FileInfo file in fileinfo)
{
if (file.Name == name)
{
string filepath = files + @"\" + name;
filecontent = new FileStream(filepath,FileMode.Open);
filebyte = new Byte[filecontent.Length];
filecontent.Read(filebyte, , filebyte.Length);
filecontent.Close();
}
}
string encodedFileName = HttpUtility.UrlEncode(name); WebOperationContext.Current.OutgoingResponse.ContentType = "application/octet-stream";
WebOperationContext.Current.OutgoingResponse.Headers.Add("Content-Disposition", string.Format("attachment;filename=\"{0}\";filename*=utf-8'' {1}", encodedFileName, encodedFileName)); return new MemoryStream(filebyte);

前段代码:

<button ng-click="imageDownload(item)">下载</button>
this.downloadAccessory=function(fileId){
location.href=hostAddress+'MapScheme/ImageDownload?name='+name;
};

效果:

angular调用WCF服务,读取文件夹下图片显示列表,下载另存为图片的更多相关文章

  1. java读取文件夹下所有文件并替换文件每一行中指定的字符串

    import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.I ...

  2. VS2010中使用Jquery调用Wcf服务读取数据库记录

    VS2010中使用Jquery调用Wcf服务读取数据库记录 开发环境:Window Servere 2008 +SQL SERVE 2008 R2+ IIS7 +VS2010+Jquery1.3.2 ...

  3. php 读取网页源码 , 导出成txt文件, 读取xls,读取文件夹下的所有文件的文件名

    <?php // 读取网页源码$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLO ...

  4. C#读取文件夹下所有指定类型,并返回相应类型数据

    C#读取文件夹下所有文件 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享.心 ...

  5. python 读取文件夹下的图片进行处理

    python的os模块中有一个listdir函数可以遍历读取文件夹下的文件. import os for filename in os.listdir(r"./file"): #l ...

  6. java读取文件夹下文件及txt内容

    public class PositionController {     // 读取txt内容     public static String txt2String(File file) {    ...

  7. QT 读取文件夹下所有文件(超级简单的方法,不需要QDirIterator)

    之前,用标准C++写过读取文件夹.现在用QT重写代码,顺便看了下QT如何实现,还是相当简单的.主要用到QDir,详细文档可见这里 A program that lists all the files ...

  8. Linux C 读取文件夹下所有文件(包括子文件夹)的文件名【转】

    转自:https://www.cnblogs.com/xudong-bupt/p/3504442.html 本文:http://www.cnblogs.com/xudong-bupt/p/350444 ...

  9. [R语言]读取文件夹下所有子文件夹中的excel文件,并根据分类合并。

    解决的问题:需要读取某个大文件夹下所有子文件夹中的excel文件,并汇总,汇总文件中需要包含的2部分的信息:1.该条数据来源于哪个子文件夹:2.该条数据来源于哪个excel文件.最终,按照子文件夹单独 ...

随机推荐

  1. BlockingQueue队列学习

    今天看了下BlockingQueue的几种实现,记录下以便以后复习. 首先来看一下BlockingQueue的家族成员: BlockingQueue除了先进先出外,还有两个操作:在队列为空时,获取元素 ...

  2. Spring MVC 解读——@RequestMapping (1)(转)

    转自:http://my.oschina.net/HeliosFly/blog/212329 Spring MVC 解读——@RequestMapping 为了降低文章篇幅,使得文章更目标化,简洁化, ...

  3. View的getLeft, getRight, getTop, getBottom

    View的getLeft, getRight, getTop, getBottom方法得到的分别是相对于其父组件原点坐标不同方向的距离 网上找了张图说明: 其中right和left的计算方法如下: r ...

  4. new 与override 区别

    using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace Newover ...

  5. 【转】MFC界面更新实现方法

    原文网址:http://www.cnblogs.com/skywatcher/p/3572311.html 1.更新窗口 即采用UpdateWindow()函数立即发送WM_PAINT消息更新整个窗口 ...

  6. HDU-1035 Robot Motion

    http://acm.hdu.edu.cn/showproblem.php?pid=1035 Robot Motion Time Limit: 2000/1000 MS (Java/Others)   ...

  7. ASP.Net 验证视图状态 MAC 失败

    错误信息: 验证视图状态 MAC 失败.如果此应用程序由网络场或群集承载,请确保 <machineKey> 配置指定了相同的 validationKey 和验证算法.不能在群集中使用 Au ...

  8. 《University Calculus》-chape4-极坐标与圆锥曲线-极坐标系下的面积与弧长

    极坐标系下的面积: 在直角坐标系下一样,这里在极坐标系下,我们面临一个同样的问题:如何求解一个曲线围成的面积?虽然两种情况本质上是一样的,但是还是存在一些细小的区别. 在直角坐标系下中,我们是讨论一条 ...

  9. Codeforces 348A Mafia

    题目链接:http://codeforces.com/problemset/problem/348/A 题目大意:N个人中找出1个人主持,剩下N-1个人参与游戏,给出每个人想参与游戏的次数,问要满足每 ...

  10. 长沙Uber优步司机奖励政策(1月18日~1月24日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...