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.
Questions tagged [filestream]
2638 questions
23
votes
3 answers
How to convert stream results to string
I want to convert the stream result output to string since I want
to use it in Junit I think that I need to use the string writer but
Im not sure how exactly to use it.
StreamResult result = new StreamResult(new…
user1578363
22
votes
1 answer
How do I load a string into a FileStream without going to disk?
string abc = "This is a string";
How do I load abc into a FileStream?
FileStream input = new FileStream(.....);
![](../../users/profiles/714869.webp)
Mennan
- 4,091
- 12
- 49
- 84
22
votes
3 answers
Http MultipartFormDataContent
I have been asked to do the following in C#:
/**
* 1. Create a MultipartPostMethod
* 2. Construct the web URL to connect to the SDP Server
* 3. Add the filename to be attached as a parameter to the MultipartPostMethod with parameter name…
![](../../users/profiles/2985419.webp)
user2985419
- 443
- 2
- 6
- 20
22
votes
4 answers
Read the actual contents of text file using FileStream and these options c#
I need to open a text file within C# using FileStream and with the options mentioned below
var fileStream = new FileStream(filePath,
FileMode.Open,
FileAccess.Read,
…
![](../../users/profiles/1776480.webp)
user1776480
- 259
- 1
- 3
- 5
21
votes
4 answers
FILESTREAM files being left behind after row deleted
I have successfully set up FILESTREAM on my SQL 2008 server; however I've noticed that even when I have deleted rows containing FILESTREAM data, the physical data file doesn't seem to get deleted.
By the physical file, I mean the file in SQLServer's…
![](../../users/profiles/95027.webp)
Dale
- 1,651
- 2
- 19
- 29
20
votes
3 answers
FileStream and StreamWriter - How to truncate the remainder of the file after writing?
var fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
using(var writer = new StreamWriter(fs))
writer.Write(....);
If the file previously contained text and the newly-written text is shorter than what was already in…
![](../../users/profiles/98389.webp)
Nathan Ridley
- 31,947
- 30
- 116
- 188
20
votes
2 answers
File.ReadLines without locking it?
I can open a FileStream with
new FileStream(logfileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Without locking the file.
I can do the same with File.ReadLines(string path)?
![](../../users/profiles/97082.webp)
Felipe Fujiy Pessoto
- 6,492
- 8
- 40
- 71
19
votes
3 answers
Python read stream
I need a very inexpensive way of reading a buffer with no terminating string (a stream) in Python. This is what I have, but it wastes a a lot of CPU time and effort. Because it is constantly "trying and catching." I really need a new approach.
Here…
![](../../users/profiles/3772603.webp)
dylnmc
- 3,276
- 3
- 20
- 37
19
votes
2 answers
StreamWriter and IFormatProvider
How do I pass an IFormatProvider to a StreamWriter?
Specifically I want to create a
new StreamWriter("myfile.txt", CultureInfo.InvariantCulture);
TextWriter and StringWriter have a parameter for that in the constructor, but StreamWriter does…
![](../../users/profiles/145999.webp)
HugoRune
- 11,755
- 6
- 57
- 129
18
votes
3 answers
Determining file extension given a FileStream
Is there any way to know the type of the FileStream. I have a function that takes a FileStream object and I want to determine the file extension based on that FileStream.
![](../../users/profiles/226161.webp)
Abdul Samad
- 4,840
- 12
- 52
- 66
18
votes
3 answers
Download pdf programmatically
How can I download a PDF and store to disk using vb.NET or C#?
The URL (of the PDF) has some rediection going on before the final PDF is reached.
I tried the below but the PDF seems corrupted when I attempt to open locally,
Dim PdfFile As FileStream…
![](../../users/profiles/219276.webp)
Perplexed
- 847
- 2
- 17
- 31
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…
![](../../users/profiles/88427.webp)
Eric Anastas
- 20,455
- 32
- 134
- 223
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…
![](../../users/profiles/106159.webp)
Matthew Watson
- 90,570
- 7
- 128
- 228
17
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!
![](../../users/profiles/314447.webp)
SaphuA
- 2,924
- 3
- 36
- 56
17
votes
3 answers
How can I detect if a .NET StreamReader found a UTF8 BOM on the underlying stream?
I get a FileStream(filename,FileMode.Open,FileAccess.Read,FileShare.ReadWrite) and then a StreamReader(stream,true).
Is there a way I can check if the stream started with a UTF8 BOM?
I am noticing that files without the BOM are read as UTF8 by the…
![](../../users/profiles/611956.webp)
bookclub
- 529
- 2
- 4
- 8