[Powershell] 讀取文字檔

當使用 Powershell 存取文字檔時, 在以前的年代需要利用System.IO 進行, 但現在只須一句便可. 

$currentDate=get-content "C:\iBossDayEndProcess\DefaultBusinessDate.txt"
Write-Host $currentDate
$formattedCurrentDate=$currentDate.Substring(2,6)
Write-Host $formattedCurrentDate

存取後的資料會以string 的形式儲存在variable中, 須要的話再自行將它cast.

About C.H. Ling 262 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.