问题描述
传递给 File.ReadAllBytes 方法的文件路径通过预先执行路径覆盖
这是在调试中使用 TopShelf 作为服务运行的控制台应用程序。
var bytes = File.ReadAllBytes(@"d:\ubuntu-20.04.2.0-desktop-amd64.iso.torrent");
System.IO.IOException: 'The filename,directory name,or volume label Syntax is incorrect. : 'C:\FR\src\Service\bin\Debug\net5.0\D:\ubuntu-20.04.2.0-desktop-amd64.iso.torrent
堆栈跟踪
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode,FileShare share,FileOptions options)
at System.IO.FileStream..ctor(String path,FileMode mode,FileAccess access,Int32 bufferSize,FileOptions options)
at System.IO.File.ReadAllBytes(String path)
at FR.Engine.Actors.FileReaderActor.OnReadFileCommand(FileReadCommand command) in C:\FR\src\FR.Engine\Actors\FileReaderActor.cs:line 18
at FR.Engine.Actors.FileReaderActor.<.ctor>b__0_0(FileReadCommand command) in C:\FR\src\FR.Engine\Actors\FileReaderActor.cs:line 11
at Akka.Tools.MatchHandler.PartialHandlerArgumentsCapture`2.Handle(T value)
at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message,PartialAction`1 partialAction)
at Akka.Actor.ReceiveActor.OnReceive(Object message)
at Akka.Actor.UntypedActor.Receive(Object message)
at Akka.Actor.ActorBase.AroundReceive(Receive receive,Object message)
at Akka.Actor.ActorCell.ReceiveMessage(Object message)
at Akka.Actor.ActorCell.Invoke(Envelope envelope)
出于调试目的,我添加了一行 - 参考 snip 的值
var fullpath = Path.GetFullPath(command.Path);
它适用于带有 Topshelf 的简单 .net5 控制台应用程序。所以我怀疑是 Akka.net 造成的。