草庐IT

Io_context

全部标签

c# - HttpContext.Current.Session 与 Context.Session

它们是一回事吗?或者它们有什么不同?我读过这个SOpost和this但他们比较的是HttpContext.Current.Session和Session而不是Context.Session。我错过了什么/误解了什么? 最佳答案 Context.Session在与HttpContext.Current.Session相同的页面中。HttpContext.Current.Session通常从不直接在页面上或没有对当前页面的引用的代码中使用。 关于c#-HttpContext.Current.

c# - 未知模块中发生类型为 'System.IO.FileNotFoundException' 的未处理异常

我正在开发一个C#应用程序,但在调试运行时出现以下错误:Anunhandledexceptionoftype'System.IO.FileNotFoundException'occurredinUnknownModule.Additionalinformation:Couldnotloadfileorassembly'Autodesk.Navisworks.Timeliner.dll'oroneofitsdependencies.Thespecifiedmodulecouldnotbefound.Autodesk.Navisworks.Timeliner.dll位于应用程序的调试文件夹

c# - 在 System.IO.Directory.GetFiles() 中排除文件扩展名

有没有办法获取文件夹中的文件数,但我想排除扩展名为jpg的文件?Directory.GetFiles("c:\\Temp\\").Count(); 最佳答案 试试这个:varcount=System.IO.Directory.GetFiles(@"c:\\Temp\\").Count(p=>Path.GetExtension(p)!=".jpg");祝你好运! 关于c#-在System.IO.Directory.GetFiles()中排除文件扩展名,我们在StackOverflow上找到

c# - 使用静态工厂 Func<T> 为 ASP.NET 应用程序创建 "Ambient Context"(UserContext)

我发现几乎每个类(Controller、View、HTML帮助程序、服务等)我都需要当前登录的用户数据。所以我考虑创建一个“环境上下文”而不是直接注入(inject)IUserService或用户。我的方法看起来像那样。publicclassBootstrapper{publicvoidBoot(){varcontainer=newContainer();//thecalltoIUserService.GetUseriscachedperHttprequest//byusingadynamicproxycachingmechanism,thatalsohandlescaseswhere

c# - 可移植类库不支持System.IO,为什么?

我创建了一个可移植类库,用于我的Monodroid项目。但问题是我需要System.IO库,但不幸的是我无法添加它。我什至尝试通过“添加引用”选项添加它,但没有成功。为什么会这样?我该怎么做? 最佳答案 您不能使用System.IO,因为它不是可移植类库。System.IO进行特定于其运行的操作系统(Windows)的调用,而可移植类库是跨平台的。可以找到您正在寻找的解决方案here:Whatshouldyoudowhenyou’retryingtowriteaportablelibrarybutyouneedsomefunctio

c# - 如何检查 System.IO.File.Delete 是否成功删除文件

使用system.io.file类删除文件后:System.IO.File.Delete(openedPdfs.path);如果文件被成功删除,我需要运行一些代码。只要该方法不返回任何值,我就会在delete方法之后检查文件是否存在。如果它仍然存在,我认为操作失败。问题是,删除方法工作正常,但要删除文件需要几秒钟。Exist函数返回true,因为当时它正在检查文件是否存在。我如何确定System.IO.File.Delete(openedPdfs.path);是否成功完成?代码:FileInfofile=newFileInfo(openedPdfs.path);System.IO.Fi

c# - 如何使用 Simple injector、Repository 和 Context - code first

我正在尝试使用SimpleInjector创建我的存储库并在业务逻辑层中使用它(我也想使用PerWebRequest方法)。在DAL层我有:publicinterfaceIRepositorywhereT:class{voidAdd(Tentity);voidDelete(Tentity);voidDelete(intid);voidUpdate(Tentity);TGetById(intId);IQueryableAll();IEnumerableFind(Funcpredicate);}和:publicclassEFRepository:IRepository,IDisposabl

c# - 如何在没有流或系统 io 的情况下压缩字节数组

我正在尝试将图像编码为字节数组并将其发送到服务器。编码和发送部分工作正常,但我的问题是字节数​​组太大,发送时间太长,所以我认为压缩它会使它运行得更快。但实际问题是我不能使用system.io或流。我的目标是.net2.0。谢谢。 最佳答案 usingSystem.IO;usingSystem.IO.Compression;代码:publicstaticbyte[]Compress(byte[]data){MemoryStreamoutput=newMemoryStream();using(DeflateStreamdstream=

c# - context.DeserializeTicket(token) 做什么?

我想了解刷新token的工作原理,我有一个很好的主意,这里有一个例子http://bit.ly/1n9Tbot,但我发现了这个context.DeserializeTicket(protectedTicket);我不确定它的作用,实际上没有任何文档,您可以在这里看到http://bit.ly/1y7LTHt是用来销毁token的吗?如果是“反序列化”,为什么不返回任何东西? 最佳答案 context.DeserializeTicket()类似于context.SetTicket()因为它们都设置了上下文的标签。区别在于Deseria

c# - 这个 Ambient Context 怎么会变成 null 呢?

谁能帮我解释一下TimeProvider.Current如何在下面的类中变为null?publicabstractclassTimeProvider{privatestaticTimeProvidercurrent=DefaultTimeProvider.Instance;publicstaticTimeProviderCurrent{get{returnTimeProvider.current;}set{if(value==null){thrownewArgumentNullException("value");}TimeProvider.current=value;}}public