zoukankan      html  css  js  c++  java
  • 将文件上传至服务器

    for (int i = 0; i < list_file.Items.Count; i++)//文件总数
    {
    FileInfo info = new FileInfo(filePath + "\" + list_file.Items[i]);
    FileStream fs = new FileStream(filePath + "\" + list_file.Items[i].ToString(), FileMode.Open, FileAccess.Read);//使用 FileStream 类对文件系统上的文件进行读取、//写入、打开和关闭操作,并对其他与文件相关的操作系统句柄进行操作,如管道、标准输入和标准输出。读写操作可以指定为同步或异步操作。FileStream 对输入输出进行//缓冲,从而提高性能。
    BinaryReader r = new BinaryReader(fs);//BinaryReader类创建对象时必须基于所提供的流文件fs。
    byte[] postArray = r.ReadBytes((int)fs.Length);//
    if (fs.CanRead)
    {
    ReportFileChileModle child = getFileChilemdl();
    ReportFileModle mdl = getFilemdl();
    child.TXT_FILENAME = System.IO.Path.GetFileNameWithoutExtension(list_file.Items[i].ToString().Trim());
    child.TXT_FILECONTENT = postArray;
    child.TXT_FILE_TYPE = System.IO.Path.GetExtension(filePath + "\" + list_file.Items[i].ToString());
    if (!rf.SaveFile(mdl, child))
    {
    MessageBox.Show("保存过程中出错", "错误");
    break;
    }
    }
    fs.Close();
    }

  • 相关阅读:
    由二进制移位想到的
    KDJ指标详解
    PMP考试结束
    转K线理论初级二
    日本地震效应
    Baseline之流水先生的见解
    KDJ判断原则
    转K线理论初级一
    管理学法则
    今天提到KW,特此@Mark一下
  • 原文地址:https://www.cnblogs.com/houzf/p/5582796.html
Copyright © 2011-2022 走看看