powershell - 无法读取文件内容
问题描述
我正在尝试读取文件的内容:
$releaseNotesPath = "$(System.DefaultWorkingDirectory)\_ccp-develop\ccp\ccp\ReleaseNotes\ReleaseNotes\"
$latestReleaseNotesFile = Get-ChildItem -Path $releaseNotesPath -Filter *.txt | Select-Object FullName,Name | Sort-Object -Property Name | Select-Object -First 1
问题出现在这里:
$releaseNote = Get-Content $latestReleaseNotesFile
2021-11-14T14:29:07.0729088Z ##[error]Cannot find drive. A drive with the name '@{FullName=D' does not exist.
2021-11-14T14:29:07.1945879Z ##[error]PowerShell exited with code '1'.
我究竟做错了什么?
解决方案
您需要提供文件路径 ( FullName
):
$releaseNote = Get-Content $latestReleaseNotesFile.FullName
推荐阅读
- ios - Can't push view controller in AppDelegate with TabBarController
- javascript - [Vue 警告]:渲染错误:“TypeError:无法获取未定义或空引用的属性‘Id’
- web-services - 使用 Jetty 配置的 Restlet
- c - 清除c中的数组数据
- php - Wamp 服务器中的错误显示错误:路径中的 C:/wamp 或 PHP
- java - 从unix机器识别windows selenium节点中下载的文件
- xamarin - 取消勾选“使用共享运行时”会产生性能问题
- c++ - 警告:非标准布局类型“DerivedClass”的偏移量
- c# - C#创建带有数字和字符的字符串序列
- node.js - 使用 Azure Functions 和 Azure Cosmos DB 时出现问题,返回“停机维护”