Raabi Anony
Raabi Anony

Reputation: 25

Basic File Operations

Please refer to my first code in PS, below: I created a Test.ps1 file and included the following code:

$path = D:\Five-Levels_Deep_Subfolder\Data

$file = A_Very_Long_INI_FileName.ini 

#If $file exists, Delete it: 
if (Test-Path + $path) { Remove-Item $path + $file } 

#Run the following Application: 
& $path + myApplication.exe

But, the result tried to terrify me with a number of horrible error messages. As a matter of fact, none of the above lines of code was error-free.

Please bear with a toddler in PS, and help me to make it a great success :-).

Upvotes: 0

Views: 867

Answers (1)

CB.
CB.

Reputation: 60938

Try this

$path = "D:\Five-Levels_Deep_Subfolder\Data"    
$file = "A_Very_Long_INI_FileName.ini"    
$filepath = join-path $path $file    
#If $filepath exists, Delete it:     
if (Test-Path  $filepath) { Remove-Item $filepath}     
#Run the following Application: 
& ($path + "\myApplication.exe")

Upvotes: 1

Related Questions