Questions tagged [filestream]

In .NET framework filestream exposes a Stream around a file, supporting both synchronous and asynchronous read and write operations. ActionScript 3 for AIR 2 and above also uses FileStream, which supports both synchronous and asynchronous read and write operations.

2765 questions
19
votes
4 answers

FileStream with locked file

I am wondering if it's possible to get a readonly FileStream to a locked file? I now get an exception when I try to read the locked file. using (FileStream stream = new FileStream("path", FileMode.Open)) Thanks!
SaphuA
  • 3,092
  • 3
  • 39
  • 58
18
votes
5 answers

Reusing a filestream

In the past I've always used a FileStream object to write or rewrite an entire file after which I would immediately close the stream. However, now I'm working on a program in which I want to keep a FileStream open in order to allow the user to…
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236
18
votes
2 answers

SQL Server 2008 FILESTREAM performance

I had some questions around the FILESTREAM capability of SQL Server 2008. What would the difference in performance be of returning a file streamed from SQL Server 2008 using the FILESTREAM capability vs. directly accessing the file from a shared…
John Livermore
  • 30,235
  • 44
  • 126
  • 216
18
votes
1 answer

Windows API seems much faster than BinaryWriter - is my test correct?

[EDIT] Thanks to @VilleKrumlinde I have fixed a bug that I accidentally introduced earlier when trying to avoid a Code Analysis warning. I was accidentally turning on "overlapped" file handling, which kept resetting the file length. That is now…
Matthew Watson
  • 104,400
  • 10
  • 158
  • 276
17
votes
1 answer

Convert a Stream to a FileStream in C#

What is the best method to convert a Stream to a FileStream using C#. The function I am working on has a Stream passed to it containing uploaded data, and I need to be able to perform stream.Read(), stream.Seek() methods which are methods of the…
Greg
  • 21,235
  • 17
  • 84
  • 107
17
votes
4 answers

FileUpload to FileStream

I am in process of sending the file along with HttpWebRequest. My file will be from FileUpload UI. Here I need to convert the File Upload to filestream to send the stream along with HttpWebRequest. How do I convert the FileUpload to a filestream?
Gopi
  • 5,656
  • 22
  • 80
  • 146
17
votes
6 answers

FileStream Create

Is this syntax FileStream fs = new FileStream(strFilePath, FileMode.Create); the same as this? FileStream fs = File.Create(strFilePath); When yes, which one is better?
user609511
  • 4,091
  • 12
  • 54
  • 86
16
votes
3 answers

How to split a large file into chunks in c#?

I'm making a simple file transfer sender and receiver app through the wire. What I have so far is that the sender converts the file into a byte array and sends chunks of that array to the receiver. This works with file of up to 256mb, but this line…
Raphael
  • 562
  • 2
  • 9
  • 21
16
votes
5 answers

Read excel file from a stream

I need a way to read a Excel file from a stream. It doesn't seem to work with the ADO.NET way of doing things. The scenario is that a user uploads a file through a FileUpload and i need to read some values from the file and import to a database. For…
Kristian
  • 733
  • 1
  • 6
  • 11
16
votes
1 answer

Parsing large xml files (1G+) in node.js

I'm having a tough time finding a node package that can parse large xml files that are 1G+ in size. Our back-end server is primarily node.js, so I'd hate to have to build another service in another language/platform just to parse the xml and write…
u84six
  • 4,604
  • 6
  • 38
  • 65
16
votes
1 answer

When using FileStream.ReadAsync() should I open the file in async mode?

The old .Net way of performing asynchronous I/O for a FileStream is to use FileStream.BeginRead() and FileStream.EndRead(). The MSDN documentation for FileStream.BeginRead() states: FileStream provides two different modes of operation: synchronous…
Matthew Watson
  • 104,400
  • 10
  • 158
  • 276
16
votes
4 answers

Read from a growing file in C#?

In C#/.NET (on Windows) is there a way to read a "growing" file using a file stream? The length of the file will be very small when the filestream is opened, but the file will be being written to by another thread. If/when the filestream "catches…
Robert Fraser
  • 10,649
  • 8
  • 69
  • 93
15
votes
3 answers

Return Stream from WCF service, using SqlFileStream

I have a WCF service, from which users can request large datafiles (stored in an SQL database with FileStream enabled). These files should be streamed, and not loaded into memory before sending them off. So I have the following method that should…
Joel
  • 8,502
  • 11
  • 66
  • 115
15
votes
5 answers

How to expose a sub section of my stream to a user

I have a stream that contains many pieces of data. I want to expose just a piece of that data in another stream. The piece of data I want to extract can often be over 100mb. Since I already have stream with the data in it it seems like a waste to…
QueueHammer
  • 10,515
  • 12
  • 67
  • 91
15
votes
4 answers

simultaneous read-write a file in C#

I have a file containing data that I'd like to monitor changes to, as well as add changes of my own. Think like "Tail -f foo.txt". Based on this thread, it looks like I should just create a filestream, and pass it both to a writer and reader. …
tbischel
  • 6,337
  • 11
  • 51
  • 73