[io.fileinfo] does not work in PowerShell Studio

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
User avatar
SuperPlated
Posts: 12
Joined: Tue Apr 22, 2014 5:27 am
Location: Redmond

[io.fileinfo] does not work in PowerShell Studio

Post by SuperPlated »

Code: Select all

Product, version and build: PowerShell Studio 2020 (64 Bit) 5.7.179
Operating system: Windows 10 Enterprise (64 Bit)
PowerShell version(s): 
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      17134  858   
32-bit version of software? NO
Morning all,

Have a curious problem. Creating a "scriptDir" variable thusly:

Code: Select all

$scriptDir = ([io.fileinfo]$MyInvocation.MyCommand.Definition).DirectoryName
This fails in PowerShell studio. If I compile down to an EXE it still fails.

Works in PowerShell ISE & VSCode.

And when I open a one-line ps1 file in PSStudio with that code, it works. I'm wondering if it has to do with STA mode?

Ideas?

Thank you!

User avatar
brittneyr
Site Admin
Posts: 570
Joined: Thu Jun 01, 2017 7:20 am
Answers: 1

Re: [io.fileinfo] does not work in PowerShell Studio

Post by brittneyr »

My apologies as it appears this post was missed.
Are you still having issues with this? I have had no issue getting the the directory name with the line you provided. Are you getting any errors?
Brittney Ryn
SAPIEN Technologies, Inc.