code-conversion icon indicating copy to clipboard operation
code-conversion copied to clipboard

FileNotFoundException when CodeConversion.exe provided with -o argument

Open dodexahedron opened this issue 1 year ago • 1 comments

Directly invoking the executable, since the script passes the wrong parameters as mentioned in #12, still doesn't work, throwing a FileNotFoundException for the output file:

CodeConversion.exe -i .\MyModule.psm1 -o .\MyModule.cs

results in:

Unhandled exception. System.IO.FileNotFoundException: Could not find file 'V:\MyModule.cs'.
File name: 'V:\MyModule.cs'
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
   at System.IO.File.ReadAllText(String path)
   at CodeConversion.Program.<>c.<Main>b__0_0(Options o) in C:\src\code-conversion\src\Program.cs:line 40
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at CodeConversion.Program.Main(String[] args) in C:\src\code-conversion\src\Program.cs:line 23

dodexahedron avatar Jun 13 '24 02:06 dodexahedron

Creating an empty file with that name, to avoid that exception, results in the program running without throwing an exception, but the file remains empty.

dodexahedron avatar Jun 13 '24 02:06 dodexahedron