.Net 中 System.IO.File 中的方法哪些是线程安全的

本文深入探讨了System.IO.File类的线程安全特性,解释了静态成员的线程安全性,并指出了实例成员可能存在的并发问题。提供了一个关于如何在多线程环境中安全地使用File类的指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

System.IO.File的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。


引用:http://msdn.microsoft.com/zh-cn/library/system.io.file.aspx

Framework 版本: v4.0.30319 说明: 由于未经处理的异常,进程终止。 异常信息: System.IO.DirectoryNotFoundException 在 System.IO.__Error.WinIOError(Int32, System.String) 在 System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean, Boolean) 在 System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean, Boolean, Boolean) 在 System.IO.StreamWriter.CreateFile(System.String, Boolean, Boolean) 在 System.IO.StreamWriter..ctor(System.String, Boolean, System.Text.Encoding, Int32, Boolean) 在 System.IO.StreamWriter..ctor(System.String, Boolean) 在 Mabinogi.Network.ReadPacket.WriteFileLog(System.String, System.String) 在 Mabinogi.Network.ServerCommInstance+AsynchReceiveObject.Receive(System.IAsyncResult) 在 System.Net.LazyAsyncResult.Complete(IntPtr) 在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 在 System.Net.ContextAwareResult.Complete(IntPtr) 在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr) 在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*) 在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
最新发布
03-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值