RocketBot icon indicating copy to clipboard operation
RocketBot copied to clipboard

Error Writing to log.

Open unoriginal-one opened this issue 10 years ago • 3 comments

[08:57:52 AM] System.AggregateException: One or more errors occurred. ---> System.IO.IOException: The process cannot access the file 'C:\Users\kcadmin\Desktop\PokeBot\Logs.txt' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding) at System.IO.File.AppendAllText(String path, String contents) at PokemonGo.RocketAPI.Client.ColoredConsoleWrite(ConsoleColor color, String text) in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 252 at PokemonGo.RocketAPI.Client.d__19.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 225 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at PokemonGo.RocketAPI.Client.d__13.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 66 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at PokemonGo.RocketAPI.Window.MainForm.d__24.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Window\MainForm.cs:line 385 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at PokemonGo.RocketAPI.Window.MainForm.d__25.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Window\MainForm.cs:line 499 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at PokemonGo.RocketAPI.Window.MainForm.d__22.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Window\MainForm.cs:line 293 ---> (Inner Exception #0) System.IO.IOException: The process cannot access the file 'C:\Users\kcadmin\Desktop\PokeBot\Logs.txt' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding) at System.IO.File.AppendAllText(String path, String contents) at PokemonGo.RocketAPI.Client.ColoredConsoleWrite(ConsoleColor color, String text) in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 252 at PokemonGo.RocketAPI.Client.d__19.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 225<---

unoriginal-one avatar Jul 29 '16 16:07 unoriginal-one

make sure, C:\Users\kcadmin\Desktop\PokeBot\Logs.txt is not open or being used while the program is running. restart your computer if nothing else.

trentonwallace avatar Jul 29 '16 16:07 trentonwallace

It was not open by anything else. That was after 33 min of the bot running. The bot did recover automatically and is running again though.

unoriginal-one avatar Jul 29 '16 16:07 unoriginal-one

there is a few places, at least three in Client.cs and MainForm.cs that use File.AppendAllText

probably just need to use a stream or check to make sure it's not in use.

trentonwallace avatar Jul 29 '16 16:07 trentonwallace