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
25
votes
3 answers

What's the difference between FileStream.Flush() and FileStream.Flush(True)?

MSDN says that FileStream.Flush(True) "also clears all intermediate file buffers.". What does "all intermediate file buffers" mean exactly?
cooldfish
  • 327
  • 1
  • 3
  • 5
24
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…
dylnmc
  • 3,810
  • 4
  • 26
  • 42
24
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
23
votes
4 answers

Angular2 Displaying PDF

I have an angular2 project with an ASP.Net Web API. I have code to retrieve a file path from my database which goes to a document on my server. I then want to display this document in the browser in a new tab. Does anybody have any suggestions how…
DaRoGa
  • 2,196
  • 8
  • 34
  • 62
23
votes
7 answers

How to ensure all data has been physically written to disk?

I understand that .NET FileStream's Flush method only writes the current buffer to disk, but dependent on Windows' disk driver and the hard disk firmware this is no guarantee that the data is actually physically written to disk. Is there a .NET or…
Stefan Schultze
  • 9,240
  • 6
  • 35
  • 42
22
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)?
Felipe Pessoto
  • 6,855
  • 10
  • 42
  • 73
22
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…
bookclub
  • 579
  • 2
  • 4
  • 8
22
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…
Dale
  • 1,711
  • 2
  • 20
  • 30
22
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…
HugoRune
  • 13,157
  • 7
  • 69
  • 144
21
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…
Perplexed
  • 877
  • 2
  • 19
  • 32
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…
Nathan Ridley
  • 33,766
  • 35
  • 123
  • 197
20
votes
3 answers

How to read UTF-8 text from file using Qt?

I have some problems with reading UTF-8 encoded text from file. My version reads only ASCII characters. #include int main() { QFile file("s.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { return -1; …
Maciej Ziarko
  • 11,494
  • 13
  • 48
  • 69
20
votes
1 answer

Create Table Throws a TextImage Error On Creation

I have a table which has one field that uses a filestream. When I attempt to insert the table I get this error Cannot use TEXTIMAGE_ON when a table has no text, ntext, image, varchar(max), nvarchar(max), non-FILESTREAM columns. Why? SQL USE…
Álvaro García
  • 18,114
  • 30
  • 102
  • 193
20
votes
3 answers

django return file over HttpResponse - file is not served correctly

I want to return some files in a HttpResponse and I'm using the following function. The file that is returned always has a filesize of 1kb and I do not know why. I can open the file, but it seems that it is not served correctly. Thus I wanted to…
Thomas Kremmel
  • 14,575
  • 26
  • 108
  • 177
19
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.
Abdul Samad
  • 5,748
  • 17
  • 56
  • 70