filestream

Passing a FileStream to WCF throws “Timeouts are not supported on this stream” exception

我是研究僧i 提交于 2019-12-10 14:51:47
问题 When trying to pass a small FileStream to my WCF service I get "Timeouts are not supported on this stream" error. Can anyone see what I'm doing wrong? Interface: [OperationContract] List<SystemClass> ReadExcelFile(System.IO.FileStream stream); Web.Config <bindings> <basicHttpBinding> <binding name="streaming" maxReceivedMessageSize="2147483647" transferMode="Streamed"> </binding> </basicHttpBinding> </bindings> <services> <service name="MISDashboard.wcfService" behaviorConfiguration="">

How is IDisposable implemented on FileStream in .Net 1.1

心已入冬 提交于 2019-12-10 14:43:42
问题 This might seem like a noddy question, but I was looking at this because I heard someone claiming that you must call Close() on a FileStream, even if it is in a using block (and they have code where Close() is being called right at the end of the block). I know that Close() is meant to call Dispose(), but I thought I'd look deeper since this is .Net 1.1 code, and the bulk of my experience has been with 2.0 on. One thing that struck me was that the MSDN documentation for FileStream has Dispose

FileStream - “The given path's format is not supported”

泄露秘密 提交于 2019-12-10 14:37:32
问题 I'm trying to use EPPlus to save a spreadsheet on our LAN. I'm using a FileStream object to do this, however whenever I attempt to instantiate the object I get the error The given path's format is not supported C# private static string _fileName = "ErroredRows_"; private static string _results = @"\\prdhilfs03\l&i-sales&mkt\WORKAREA\Agencyservices\Shared\AIC\Analysts_and_Reporting\Realignments\2014\MassUpdateTesting\Results\"; public static void WriteSpreadsheet(Dictionary<DataRow, string>

Why is my Stream not Readable?

强颜欢笑 提交于 2019-12-10 14:34:44
问题 This is a sequel to my question here about trimming the fat off a log file. I have this code: private readonly FileStream _fileStream; private readonly StreamWriter _streamWriter; . . . const int MAX_LINES_DESIRED = 1000; string uriPath = GetExecutionFolder() + "\\Application.log"; string localPath = new Uri(uriPath).LocalPath; if (!File.Exists(localPath)) { File.Create(localPath); } _fileStream = File.OpenWrite(localPath); // First, remove the earliest lines from the file if it's grown too

FileStream.close() does not free file for other processes

丶灬走出姿态 提交于 2019-12-10 13:29:14
问题 I have Following Code in a Page_Load called function. When the Page is loaded the first time after starting Visual Studio, everything works out fine. But any other opening call to the File after that returns IOException: "File is in use by another process" , even when directly opening the File in VisualStudio Solution this Error is returned(of course not as Exception) FileStream mailinglist_FileStream = new FileStream(@"\foobarFile.txt", FileMode.Open); PeekingStreamReader mailinglist_Reader

Programatically find out a file type by looking its binary content. Possible?

本秂侑毒 提交于 2019-12-10 13:23:38
问题 I have a c# component that will recieve a file of the following types .doc, .pdf, .xls, .rtf These will be sent by the calling siebel legacy app as a filestream. So... [LegacyApp] >> {Binary file stream} >> [Component] The legacy app is a black box that cant be modified to tell the component what file type (doc,pdf,xls) it is sending. The component needs to read this binary stream and create a file on the filesystem with the right extension. Any ideas? Thanks for your time. 回答1: On Linux/Unix

FileStream “cannot access closed file”

心不动则不痛 提交于 2019-12-10 13:06:58
问题 Why am I receiving the above error message when I use using (fileStream = new FileStream(path, FileMode.Append, FileAccess.Write)) but the programme executes perfectly when I replace it with fileStream = File.Create(path); ? I want to append the console output to an external file. Here's my code: //copy console output to file in bin\Debug folder class ConsoleCopy : IDisposable { FileStream fileStream; StreamWriter fileWriter; TextWriter doubleWriter; TextWriter oldOut; class DoubleWriter :

Synchronization requirements for FileStream.(Begin/End)(Read/Write)

自闭症网瘾萝莉.ら 提交于 2019-12-10 12:45:20
问题 Is the following pattern of multi-threaded calls acceptable to a .Net FileStream? Several threads calling a method like this: ulong offset = whatever; // different for each thread byte[] buffer = new byte[8192]; object state = someState; // unique for each call, hence also for each thread lock(theFile) { theFile.Seek(whatever, SeekOrigin.Begin); IAsyncResult result = theFile.BeginRead(buffer, 0, 8192, AcceptResults, state); } if(result.CompletedSynchronously) { // is it required for us to

How to print next line in python

二次信任 提交于 2019-12-10 11:56:30
问题 I am trying to print next 3 lines after a match for example input is : Testing Result test1 : 12345 test2 : 23453 test3 : 2345454 so i am trying to search "Result" string in file and print next 3 lines from it: Output will be :- test1 : 12345 test2 : 23453 test3 : 2345454 my code is : with open(filename, 'r+') as f: for line in f: print line if "Benchmark Results" in f: print f print next(f) its only giving me the output : testing how do i get my desired output, help please 回答1: First you

How do I upload an image to a ServiceStack service?

為{幸葍}努か 提交于 2019-12-10 11:48:00
问题 I have the path of an image, and use the following code to send it to my server; HttpWebRequest client = (HttpWebRequest)WebRequest.Create("http://212.175.132.168/service/api/upload/cab.jpg"); client.Method = WebRequestMethods.Http.Post; // the following 4 rows enable streaming client.AllowWriteStreamBuffering = false; client.SendChunked = true; client.ContentType = "multipart/form-data;"; client.Timeout = int.MaxValue; using (FileStream fileStream = System.IO.File.OpenRead (filePath)) {