Simultaneously storing and returning a FileStream

I've got a method that streams files by returning a System.IO.FileStream pointing to a file opened for reading. What I want to do at this point is store the stream into a System.IO.MemoryStream as well. The simplest option would be to first read the FileStream into the MemoryStream, and then return the MemoryStream to the caller. However this means that I'll have to buffer the entire

同时存储和返回FileStream

我有一个方法通过返回一个System.IO.FileStream指向打开的文件来读取流文件。 我现在想要做的是将流存储到System.IO.MemoryStream中。 最简单的选择是首先将FileStream读入MemoryStream,然后将MemoryStream返回给调用者。 但这意味着我必须在返回之前将整个文件缓冲到内存中,从而延迟对调用者的流式响应。 我想做什么(如果可能的话)是将FileStream读入一个MemoryStream,并将其同时传送给调用者。 这样,文件在返回之

StreamReader returning another char

I'm trying to read the content of a file with a StreamReader, that receives a FileStream. The file has some spaces inside (char 32) and the StreamReader is reading them as 0 (char 48). The screenshot shows the FileStream buffer and the StreamReader buffer. Both have the value 32, but when I call Read(), it returns 48. Am I missing something here? By the way, the code is running under .NET

StreamReader返回另一个字符

我正在尝试使用StreamReader读取文件的内容,该文件接收FileStream。 该文件中有一些空格(char 32),StreamReader将它们读为0(char 48)。 屏幕截图显示了FileStream缓冲区和StreamReader缓冲区。 两者都有值32,但是当我调用Read()时,它返回48.我在这里丢失了什么? 顺便说一下,代码在.NET Compact Framework下运行。 替代文字http://www.freeimagehosting.net/uploads/9f72b61bbe.png 读取数据的代码: public

Read embedded file from assembly

I have to pass the path of a config file to a framework method (Gurok SmartInspect). The config file is an embedded resource of the assembly. Currently I read the file from the assembly and store it outside and then pass the pathName. Is there a better / less complicated way to achieve this goal, without copying the file? private static void ConfigLogger() { const string embed

从程序集中读取嵌入文件

我必须将配置文件的路径传递给框架方法(Gurok SmartInspect)。 配置文件是程序集的嵌入式资源。 目前我从程序集中读取文件并将其存储在外部,然后传递路径名。 有没有更好/更复杂的方式来实现这个目标,而不复制文件? private static void ConfigLogger() { const string embeddedFileName = "xxx.SmartInspect.properties"; const string configFileName = "SmartInspect.properties"; E

How do I get an SQLCe sdf databases locale identifier?

I'm trying to read a database using a connection string like so: "Data Source = '" + _SourceDirectory + "'; LCID=SomeLocale" My issue is when I try to connect to an SDF database I copied from a Windows Mobile device I get the error that the Locale ID is not supported (-1 when I don't specify one). I need to be able to open the database and read from it.

我如何获得SQLCe sdf数据库区域设置标识符?

我试图用连接字符串读取数据库,如下所示: “Data Source ='”+ _SourceDirectory +“'; LCID = SomeLocale” 我的问题是,当我尝试连接到从Windows Mobile设备复制的SDF数据库时,出现Locale ID不受支持的错误(-1,当我没有指定它时)。 我需要能够打开数据库并从中读取数据。 有任何想法吗? 好吧,我“修复”了这一点,SDF文件可能已经损坏,因为我从设备中取出新的文件后没有问题。

How do I stop Visual C# 2005 crashing when debugging on a windows mobile device?

I'm attempting to debug a .NET Compact framework C# application on a Windows Mobile 6 device using Visual Studio 2005. If execution reaches a breakpoint I have previously set, 9 times out of 10 it crashes. If it doesn't crash first time, that breakpoint will continue working correctly, even through multiple executions of the application. I get an exception code 0xC0000005 (STATUS_ACCES

在Windows Mobile设备上进行调试时,如何停止Visual C#2005崩溃?

我试图在使用Visual Studio 2005的Windows Mobile 6设备上调试.NET Compact框架C#应用程序。如果执行达到我以前设置的断点,则10次中有9次崩溃。 如果它不是第一次崩溃,即使通过应用程序的多次执行,该断点也将继续正常工作。 我在地址0x00000000015fab774处得到一个异常代码0xC0000005(STATUS_ACCESS_VIOLATION)。 这是一个本地例外。 在托管应用程序中,这通常是由您的某个P / Invokes或WindowsCE自定义版本中的缺陷

Efficiently sort an IList<T> without copying the source list

Given the test case below how can I: Sort the IList<TestObject> based on the index of a matching Id in the IList<int> list. Unmatched values are moved to the end of the list and sorted by their original index. In this case, since 3 and 4 do not exist in the index list, we expect to see list[3] == 3 and list[4] == 4 . Whilst I know this can be achieved with linq, I need to resor

在不复制源列表的情况下有效排序IList <T>

鉴于下面的测试案例,我该如何: 根据IList<int>列表中匹配Id的索引对IList<TestObject>排序。 不匹配的值将移动到列表的末尾并按其原始索引排序。 在这种情况下,由于3和4不存在于索引列表中,我们期望看到list[3] == 3和list[4] == 4 。 虽然我知道这可以通过linq来实现,但我需要使用原始列表而不是创建一个新列表(由于列表存储的方式)。 源列表必须是IList (我不能使用List<T> ) 这是测试

ircDotNet bot fails to get messages from IRC channel, long login/logout

I'm trying to write bot for irc channel, which will read messages from channel, recognize if they are commands to him and do some actions depends on command which was send. I've choose ircDotNet because it was the only library that contains some examples how to use it, but they are actually very outdated, only half of them works. My lack of experience in C# and in programming at all don

ircDotNet bot无法从IRC频道获取消息,长时间登录/注销

我试图为irc通道编写bot,它将从通道读取消息,识别它们是否是对他的命令,并根据发送的命令执行一些操作。 我选择了ircDotNet,因为它是唯一包含一些示例如何使用它的库,但它们实际上已经过时,只有一半可以使用。 我在C#和编程方面缺乏经验并不能让我理解没有好例子的东西:( 所以我的程序现在做了什么: 使用密码登录到服务器 加入频道 注销(非常错误) 我无法捕获并发送任何来自某个频道的消息,而且我无法立

IRC Client C# PING request

I'm trying to write my own IRC Client an i think i'm stuck where i should send the PONG response. Everything my code currently does, is sending the logon informations ("NICK USERNAME" and "USER USERNAME...") That works so far, but the server quits my connection after that. This is what the server says: :eu.german-elite.net NOTICE AUTH :*** Looking up your hostname..

IRC客户端C#PING请求

我试图写我自己的IRC客户端,我认为我卡在哪里,我应该发送PONG响应。 我的代码目前所做的一切都是发送登录信息(“NICK USERNAME”和“USER USERNAME ...”)。目前为止,这种方式很有效,但服务器在此之后退出了连接。 这是服务器说的: :eu.german-elite.net NOTICE AUTH :*** Looking up your hostname... :eu.german-elite.net NOTICE AUTH :*** Found your hostname (cached) :eu.german-elite.net NOTICE AUTH :*** Checkin

VS 2017 + cmake + ninja + mingw

I'm using VS 2017's new "open folder" feature with automatic cmake builds via CmakeSettings.json. The code is written in C11, so I need to compile it with gcc (from mingw-64). I created a new cmake configuration that looks like this: { "name": "GNU-Debug", "generator": "Ninja", "configurationType": "Debug", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "$

VS 2017 + cmake + ninja + mingw

我正在使用VS 2017的新“打开文件夹”功能,通过CmakeSettings.json自动创建cmake。 代码是用C11编写的,所以我需要用gcc(来自mingw-64)编译它。 我创建了一个新的cmake配置,如下所示: { "name": "GNU-Debug", "generator": "Ninja", "configurationType": "Debug", "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${env.USERPROFILE}\CMakeBuilds\${workspaceHash}\build\${name}", "installRoot"

Why doesn't GCC show vectorization information?

I'm using Codeblocks for a C program on Windows 7. The program is using the OMP library. GCC version is 4.9.2. Mingw x86_64-w64-mingw32-gcc-4.9.2.exe. Flags used are: -fopenmp -O3 -mfpmath=sse -funroll-loops -ftree-loop-distribution -ftree-vectorize -ftree-vectorizer-verbose=2 . The program runs correctly but the problem is that it doesn't show information on what loops were vectori

为什么GCC不显示矢量化信息?

我在Windows 7上为C程序使用Codeblocks。该程序正在使用OMP库。 GCC版本是4.9.2。 Mingw x86_64-w64-mingw32-gcc-4.9.2.exe。 使用的标志是: -fopenmp -O3 -mfpmath=sse -funroll-loops -ftree-loop-distribution -ftree-vectorize -ftree-vectorizer-verbose=2 。 该程序运行正常,但问题是它不显示有关哪些循环是矢量化的信息。 我该如何解决它? 生成日志信息: --------------编译:在****发布(编译器:GNU GCC