Folgender code:
string test = "hallo";
string file = "D:\\output_status.txt";
File.WriteAllText(file,test);
Exception :
Der Prozess kann nicht auf die Datei D:\output_status.txt zugreifen, da sie von einem anderen Prozess verwendet wird.
Stack:
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei 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)
bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
bei System.IO.StreamWriter.CreateFile(String path, Boolean append)
bei System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
bei System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
bei System.IO.File.WriteAllText(String path, String contents, Encoding encoding)
bei System.IO.File.WriteAllText(String path, String contents)
bei eFMiddleware.MiddlewareController.writeStatusToFile(String& result, String fileName) in ...Program.cs:Zeile 572.
Die Datei wird hier erst erstellt, niemand greift auf diese Datei zu und ich kann diese Datei problelos löschen.
WriteAllText schließt doch die Datei direkt, warum macht er da solche Probleme?
Life is a short
Edit: Gelöst
Es war noch n Fragment im Code drin, der unnützerweise n XMLTextWriter erstellt hat, der genauso heißt 😠
Life is a short