Named pipes server read timeout

When using C# NamedPipeServerStream, in case a client doesn't send any message-end-pattern (like rn when server reads with ReadLine()) NamedPipeServerStream Read methods will wait forever and no Abort() or Interupt() methods will work on that thread. Since: 1) Stream.ReadTimeout not supported for NamedPipeServerStream 2) Abort() or Interupt() doesn't work on thread 3) NamedPipeSer

命名管道服务器读取超时

当使用C#NamedPipeServerStream时,如果客户端不发送任何消息结束模式(例如服务器使用ReadLine()读取时的 r n),NamedPipeServerStream读取方法将永远等待,并且不会有Abort()或Interupt()方法在该线程上工作。 以来: 1)Stream.ReadTimeout不受NamedPipeServerStream支持 2)Abort()或Interupt()在线程上不起作用 3)NamedPipeServerStream.Disconnect()可以工作 目前还不清楚,如何在NamedPipeServ

Determine if an application is blocked/busy?

I'm trying to automate the GUI of an external application using C#/.NET 4.0 The application that's being automated (AUT) is a VB6 app. When doing an action, or clicking a button, the AUT sometimes spends a lot of time waiting for the DB to respond. When the app is waiting for the DB results, the app itself is idle (doesn't register much CPU usage), but it's blocked (you can&#

确定应用程序是否被阻止/忙碌?

我试图使用C#/ .NET 4.0自动化外部应用程序的GUI 正在自动化的应用程序(AUT)是一个VB6应用程序。 在做某个动作或点击一个按钮时,AUT有时会花费很多时间等待数据库响应。 当应用程序正在等待数据库结果时,应用程序本身是空闲的(不会注册太多CPU使用率),但它被阻止(您不能单击或与其交互)。 到目前为止,我已经尝试将鼠标指针(沙漏)作为指标,但有时应用程序被阻止,但光标正常。 所以这是不可靠的。 - 我

JSON serialization of enum as string

I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer , my json result contains the integer value of the enumeration rather than its string "name". Is there a way to get the enum as a string in my json without having to create a custom JavaScriptConverter ? Perhaps there's an attribute that I could decorate the enum definition, o

JSON序列化为字符串的枚举

我有一个包含enum属性的类,在使用JavaScriptSerializer序列化对象时,我的json结果包含枚举的整数值而不是其string “name”。 有没有办法让我的json中的string枚举而不必创建自定义的JavaScriptConverter ? 也许有一个属性,我可以装饰enum定义,或对象属性,用? 举个例子: enum Gender { Male, Female } class Person { int Age { get; set; } Gender Gender { get; set; } } 期望的json结果: { "Age": 35,

Check if display is turned off by windows power management

How can I programmatically check in Windows 7 and XP if 'windows power management' has turned off the display? (If I can receive an event, that would be even better.) I don't think it can be done for XP. In Windows 7 there are all kinds of goodies related to power management. The Windows API Code Pack is a set of managed wrappers that are simple to call from C# or VB and that map

检查显示器是否由Windows电源管理关闭

如何在Windows 7和XP中以编程方式检查“Windows电源管理”是否关闭了显示屏? (如果我能收到一个事件,那会更好。) 我不认为它可以为XP做。 在Windows 7中,有各种与电源管理相关的好东西。 Windows API代码包是一组托管包装,可以很容易地从C#或VB中调用,并将Windows范例(如事件接收器,Windows消息和函数指针)映射到.NET代码中(如代理和事件)。随代码包一起提供的管理演示,以下是您可能会喜欢的一些代码: using M

Directory Permission Watcher in c#

I have created the program which is monitoring a directory (eg \serversharefolderXYZ ) for changed events (like created, deleted, renamed and permission changes). I also got the notification if anything changed but I can't get exact details what has changed. For example I have changed the permission for above directory from folder properties (Properties -> Security -> Edit ->Add n

目录权限观察者在C#

我创建了监视目录(例如\serversharefolderXYZ )的程序,用于更改事件(如创建,删除,重命名和权限更改)。 如果有任何更改,我也会收到通知,但我无法获得确切的详细信息。 例如,我已经从文件夹属性(属性 - >安全 - >编辑 - >添加新用户或组或更改用户和组的权限)更改了上述目录的权限。 如果文件系统观察者发生了某些变化,则会发出通知,但我无法获取其他详细信息 哪些用户权限已更改? 谁更改了用户权

Using .NET, how can you find the mime type of a file based on the file signature not the extension

我正在寻找一种简单的方法来获取文件扩展名不正确或未提供的MIME类型,类似于仅在.Net中的此问题。 In Urlmon.dll, there's a function called FindMimeFromData . From the documentation MIME type detection, or "data sniffing," refers to the process of determining an appropriate MIME type from binary data. The final result depends on a combination of server-supplied MIME type headers, fil

使用.NET,如何根据文件签名而不是扩展名找到文件的MIME类型

我正在寻找一种简单的方法来获取文件扩展名不正确或未提供的MIME类型,类似于仅在.Net中的此问题。 在Urlmon.dll中,有一个名为FindMimeFromData的函数。 从文档中 MIME类型检测或“数据嗅探”是指从二进制数据中确定适当的MIME类型的过程。 最终结果取决于服务器提供的MIME类型标头,文件扩展名和/或数据本身的组合。 通常,只有前256个字节的数据是重要的。 因此,请从文件中读取第一个(最多)256个字节并将其传递给Fin

Get MIME type from filename extension

我如何从文件扩展名获取MIME类型? UPDATE For up-to-date mapping with additions from many contributors, see this GitHub repository: https://github.com/samuelneff/MimeTypeMap I've found many mime types my application uses are not in the default Windows registry and others are in the registry but not in the list included with IIS. I've compiled a list from these locations and added a f

从文件扩展名获取MIME类型

我如何从文件扩展名获取MIME类型? UPDATE 要获得来自许多贡献者添加的最新映射,请参阅此GitHub存储库: https://github.com/samuelneff/MimeTypeMap 我发现我的应用程序使用的许多MIME类型不在默认的Windows注册表中,其他注册表位于注册表中,但不在IIS中包含的列表中。 我从这些位置编制了一份清单,并添加了一些我们使用的其他清单。 编辑:在这里看到最新的最新版本,包括一个有效的和确定性的双向映射。 NuGet

Type for Excel XML (ASP.NET 3.5)

I use CarlosAG-Dll which creates a XML-Excel-file for me (inside a MemoryStream). Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("content-disposition", "myfile.xml"); memory.WriteTo(Response.OutputStream); My Problem here is, that I get at client side a myfile.xls (IE) or a myfile.xml.xls (FF) and therefore get an annoying security warning from excel. I tried it as w

输入Excel XML(ASP.NET 3.5)

我使用CarlosAG-Dll为我创建了一个XML-Excel文件(在MemoryStream中)。 Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("content-disposition", "myfile.xml"); memory.WriteTo(Response.OutputStream); 我的问题在于,我在客户端获得了myfile.xls(IE)或myfile.xml.xls(FF),因此会从Excel中获取恼人的安全警告。 我尝试了它,以及application / vnd.openxmlformats-officedocument.spread

iTextSharp is producing a corrupt PDF with Response

i tryed both, but still not working iTextSharp + FileStream = Corrupt PDF file iTextSharp is producing a corrupt PDF using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { //abre o documento para poder editar document.Open(); //Adiciona os campos de assinatura document.Add(Assinatura()); //fecha o doc

iTextSharp正在生成带有响应的损坏PDF

我尝试了两种,但仍然没有工作 iTextSharp + FileStream =损坏的PDF文件 iTextSharp正在生成一个损坏的PDF using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { //abre o documento para poder editar document.Open(); //Adiciona os campos de assinatura document.Add(Assinatura()); //fecha o documento ao finaliz

Do you need Adobe PDF installed on server to work with iTextSharp?

I've developed a solution on my development machine where it: Opens PDFs for a file path server side via C# Merges them together Does a Response.BinaryWrite to push to a browser the merged PDF Works great on local DEV. When pushed to server, it gets some 'binary gibberish' in the browser window. Adobe or Foxit Reader is NOT installed on the server, however it is installed o

你需要在服务器上安装Adobe PDF以使用iTextSharp吗?

我在开发机器上开发了一个解决方案: 通过C#打开文件路径服务器端的PDF文件 将它们合并在一起 是否将Response.BinaryWrite推送到合并的PDF浏览器 在本地DEV上效果很好。 当推送到服务器时,浏览器窗口中会出现一些“二进制乱码”。 Adobe或Foxit Reader未安装在服务器上,但它安装在本地开发机器上。 我的理解是,iTextSharp允许你不需要安装PDF阅读器,但它呢? 或者,也许这是一个IIS的东西.pdf不列为文件类型...