最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#獲取指定目錄下指定文件的方法

 更新時間:2022年04月14日 12:59:52   作者:農(nóng)碼一生  
這篇文章介紹了C#獲取指定目錄下指定文件的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

1.首先,需要指定獲取的文件夾,以及獲取文件的文件名;

文件夾:strLocalPath = System.Windows.Forms.Application.StartupPath + "\\ExcelTemplate\\";

文件名:temp.xlsx

2.代碼:

ExecutionResult result = new ExecutionResult();
 result.Status = true;
 string strLocalPath = System.Windows.Forms.Application.StartupPath + "\\ExcelTemplate\\";
 if (Directory.Exists(strLocalPath))
 {
 foreach (string GCFile in Directory.GetFiles(strLocalPath, "temp.xlsx", SearchOption.TopDirectoryOnly))
    {
   string fileName = Path.GetFileName(GCFile);
   string filename = Path.GetFileName(GCFile).Replace(".xlsx", "") + DateTime.Now.ToString("_yyyyMMdd") + ".xlsx";
        try
         {
        File.Copy(strLocalPath + fileName, strLocalPath + "Temp\\" + filename, true);
        result = GetA31DayData(strLocalPath + "Temp\\" + filename);
         }
      catch (Exception ex)
          {
         result.Status = false;
         result.Message = "copy file to destination file exception. Msg:" + ex.Message;
         result.Anything = ex.Message;
   if (mesLog.IsErrorEnabled)
   {
 mesLog.Error(ex.StackTrace);
    }
        }
           }
     }
  else
 {
 result.Status = false;
 result.Message = "Directory not exists!";
  }
    return result;

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

波密县| 明光市| 柳河县| 临清市| 桃园市| 土默特左旗| 烟台市| 张家界市| 武穴市| 互助| 鄂伦春自治旗| 桃园县| 淳化县| 吉安县| 和顺县| 祥云县| 广南县| 高密市| 卢龙县| 罗田县| 阿坝| 丹东市| 隆子县| 萝北县| 阜平县| 灵川县| 武乡县| 浏阳市| 通州市| 临夏县| 钟山县| 虹口区| 台前县| 古交市| 稻城县| 石嘴山市| 周宁县| 淮阳县| 怀安县| 前郭尔| 来宾市|