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
15
votes
8 answers

PHP Streaming MP3

I have a very similar situation to the person who asked: Can I serve MP3 files with PHP? Basically I am trying to protect mp3 files from direct download, so users have to go through php to get authenticated first. Here's my…
Yuval Karmi
  • 26,277
  • 39
  • 124
  • 175
15
votes
2 answers

Difference between basic_istream<>::tellg() and basic_ostream<>::tellp()

I was just wondering why the member functions tellg() defined in basic_istream<> class and tellp() defined in basic_ostream<> class have different names. Is that because basic_fstream<> is derived from basic_istream<> and basic_ostream<> ?
John Kalane
  • 1,163
  • 8
  • 17
14
votes
1 answer

The morass of Exceptions related to opening a FileStream

Ok, so I have searched in many places for the answer to this question, but I'm open to any links if I missed something obvious. I am interested in producing reasonable error messages to the user when they attempt to open a particular file, but…
skybluecodeflier
  • 1,339
  • 13
  • 26
14
votes
3 answers

How do I convert encoding of a large file (>1 GB) in size - to Windows 1252 without an out-of-memory exception?

Consider: public static void ConvertFileToUnicode1252(string filePath, Encoding srcEncoding) { try { StreamReader fileStream = new StreamReader(filePath); Encoding targetEncoding = Encoding.GetEncoding(1252); string…
14
votes
6 answers

Best strategy for storing documents in SQL Server 2008

One of our teams is going to be developing an application to store records in a SQL2008 database and each of these records will have an associated PDF file. There is currently about 340GB of files, with most (70%) being about 100K, but some are…
DCNYAM
  • 11,966
  • 8
  • 53
  • 70
14
votes
2 answers

Check SQL Server 2008 Filestream status

I'm using the SQL Server 2008 filestream feature in one of my projects, is there a way to check the filestream status (if it's enabled or not) using a query?
reggieboyYEAH
  • 870
  • 3
  • 11
  • 28
14
votes
5 answers

Example of Why stream::good is Wrong?

I gave an answer which I wanted to check the validity of stream each time through a loop here. My original code used good and looked similar to this: ifstream foo("foo.txt"); while (foo.good()){ string bar; getline(foo, bar); cout <<…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
14
votes
3 answers

OutOfMemoryException when I read 500MB FileStream

I'm using Filestream for read big file (> 500 MB) and I get the OutOfMemoryException. Any solutions about it. My Code is: using (var fs3 = new FileStream(filePath2, FileMode.Open, FileAccess.Read)) { byte[] b2 =…
Alhambra Eidos
  • 1,515
  • 4
  • 21
  • 31
14
votes
9 answers

Why does BinaryWriter prepend gibberish to the start of a stream? How do you avoid it?

I'm debugging some issues with writing pieces of an object to a file and I've gotten down to the base case of just opening the file and writing "TEST" in it. I'm doing this by something like: static FileStream fs; static BinaryWriter w; fs = new…
Chris
  • 21,549
  • 25
  • 71
  • 99
13
votes
3 answers

FileStream Read/Write method's limitation

FileStream's read/write method can take only integer value as length. But FileStreamobject returns length in long. In this case, what if file size is larger than integer value (approximate more than 2GB). Then how FileStream's read/write method…
Amit
  • 21,570
  • 27
  • 74
  • 94
13
votes
6 answers

Upload a file with encoding using FTP in C#

The following code is good for uploading text files, but it fails to upload JPEG files (not completely - the file name is good but the image is corrupted): private void up(string sourceFile, string targetFile) { try { string…
Asaf
  • 3,067
  • 11
  • 35
  • 54
13
votes
1 answer

Are Stream.ReadAsync and Stream.WriteAsync supposed to alter the cursor position synchronously before returning or after the operation completes?

I've been attempting to implement a Stream that supports ReadAsync and WriteAsync, and given the spareseness of the documentation, I'm struggling to understand how to do so properly. Specifically, with respect to the stream's cursor position. A…
James
  • 3,551
  • 1
  • 28
  • 38
13
votes
5 answers

SQL Server 2008: Unable to remove a FileStream File and Filegroup

With SQL Server 2008 SP1, I've removed the only table that had a Filestream associated with it but each time I attempt to do the following: alter database ConsumerMarketingStore remove file CMS_JobInstanceFiles alter database ConsumerMarketingStore…
James Alexander
  • 6,132
  • 10
  • 42
  • 56
13
votes
3 answers

Replacing a string within a stream in C# (without overwriting the original file)

I have a file that I'm opening into a stream and passing to another method. However, I'd like to replace a string in the file before passing the stream to the other method. So: string path = "C:/..."; Stream s = new FileStream(path, FileMode.Open,…
Prabhu
  • 12,995
  • 33
  • 127
  • 210
13
votes
4 answers

SQL Server FILESTREAM limitation

I am looking at FILESTREAM attribute in SQL Server to store files in it. I understand it stores the files on hard drive and stores the file pointer/path information in DB. Also, maintains transactional consistency in the process. There also seems to…
pencilslate
  • 12,958
  • 18
  • 58
  • 73