filestream

Create file with DeleteAfterOpen, and allow other process to read the file

Is it possible to create a file using the FileStream object in .net, specifying DeleteAfterClose option and allow read access to that file? I've tried using: System.IO.FileStream strBMP = new System.IO.FileStream(sFileName, System.IO.FileMode.Create, System.Security.AccessControl.FileSystemRights., System.IO.FileShare.ReadWrite, 1024, ...

Php Record Buffer Fread Problem

function Ifurl($subject) { $pattern = "/http:\/\//"; $regex = preg_match_all($pattern, $subject, $array); if ($regex == 1) { return true; //true that it exist } else { return false; //flase mother fucker! } } function g...

how to set a network path for filestream filegroup

How to configure a database so that filestream data is stored on a non local path? To enable filestream at db level I do first: ALTER DATABASE MyDatabase ADD FILEGROUP FileStreamFileGroup CONTAINS FILESTREAM; GO Then: ALTER DATABASE MyDatabase ADD FILE ( NAME = MyDatabaseFileStreamFile, FILENAME = 'c:\Test') TO FILEGRO...

Certain Files getting corrupted by SQL Server FileStream

I am saving files to a SQL server 2008 (Express) database using FILESTREAM, the trouble I'm having is that certain files seem to be getting corrupted in the process. For example if I save a word or excel document in one of the newer formats (docx, or xslx) then when I try to open the file I get an error message saying that the data is c...

Please Advise on Performance in C# File Encryption

I have created a test (not real) encryption function which takes a byte[] and replaces all the bytes with 0xff and returns private byte[] encrypt(byte[] input) { for (int i = 0; i < input.Length; i++) { input[i] = 0xff; } return input; } Now i want ...

Reading multiple records from Text file in C#

Hi all I need some logic/programming help with reading more than one record from a text file. I can read line for line, but I need to stop as soon as the record is finished, push that object to a list, and then continue with a new record until the next one comes up, save to list, etc... The header of the record always start with G as t...

Encrypting files in resource constrained mobile devices

So the basic question is in encrypting files in resource constrained devices. I have used a rather dangerous approach to use two FileStreams, where FileStream 1 is reading from the file and copying it to a byte array The contents of the byte array is encrypted. FileStream 2, writes the bytes back to the same file. This works fine b...

How to manage huge amount of data using filestream since only local paths are supported for data storage?

As pointed out in this question when using filestream with sql server 2008 the data must be stored locally. This means that I cannot use \\FILESERVER\FileStreamData\MyDatabase for Filestream filegroup path. So if I need to use filesrteam and have lots of data, is buying a very large hard drive the only solution (this could be quite l...

Out of memory error as inserting a 600MB files into sql server express as filestream data

(please read the update section below, I leave the original question too for clarity) I am inserting many files into a SQL Server db configured for filestream. I am inserting in a loop the files from a folder to a database table. Everything goes fine until I try to insert a 600 MB file. As it inserts it there is a +600MB memory usage...

Can't write to file using binarywriter

Why does this code not write my string to the file: string file = "Myfile.txt"; MemoryStream ms = new MemoryStream(); void writeToFile(string text) { System.Text.ASCIIEncoding encoding=new System.Text.ASCIIEncoding(); byte[] barr = encoding.GetBytes(text); ms.Write(barr, 0, barr.L...

problems sending picture from client to server

i am trying to send a picture from 'C:\picture.bmp' to 'c:\temp\picture.bmp' using server and client socket clients onconnect event handler is as follow: procedure TForm2.ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket); var fs : tfilestream; begin fs := TFileStream.create('C:\picture.bmp', fmOpenRead);//pictu...

Secure Wiping of files in Compact Framework

Given the path of a string i want to wipe out the contents of a file. The natural way I thought (which maybe incorrect) was to open a FileStream to the file and write gibberish (random data perhaps taken from a RNGCryptoServiceProvider) to it. And then perhaps do this several times and then delete the file. My problem is that while thi...

coding this function without memory leak! - please advise

Hello, In the following code example,will filestream and streamreader get disposed or will they create memory leaks? Is it possible to code this function without causing memory leaks? string ReadFile(string strPath) { using (FileStream fstream = new FileStream(strPath, FileMode.Open)) { using (Stre...

Reading / Writing text file repeatedly / simultaneously

Hello, How do I read and write on a text file without getting the exception that "File is already in use by another app"?? I tried File.readalltext() and File.Appendalltext() functions..I'm just starting out with filestream. Which would work out best in my scenario? I would appreciate some code snipplets too .. Thanks ...

When should I slurp a file, and when should I read it by-line?

Imagine that I have a C# application that edits text files. The technique employed for each file can be either: 1) Read the file at once in to a string, make the changes, and write the string over the existing file: string fileContents = File.ReadAllText(fileName); // make changes to fileContents here... using (StreamWriter writer = ...

FileStream.EndWrite throws an exception (.NET)

I'm trying to implement the progress notification mechanism when copying files. I'm doing this in the following way: I create two FileStreams - for reading and writing Call the BeginRead passing to it a ReadCallback and a structure containing the reading stream and the array to fill with the data read from a file. In the ReadCallback I...

Delphi TFileStream.Seek, how to check for invalid seek offset

I am working with TFileStream in Delphi 2006. When I invoke TFileStream.Seek with an offset that is out of bounds I am getting different return values. When I seek to a position below the beginning of the stream, the function returns -1 and if I seek to a beyond the stream size, the function returns what would have been the position in t...

Can a FileStream be promoted from Read-Only to Read-Write?

Is there a way to promoting a Read-Only FileStream to Read-Write? I am looking for functionality similar to the Win32 SDK function ReOpenFile. ...

Loading Image to Filestream

Hi, I am loading an image using OpenFileDialog open = new OpenFileDialog(); After I select the file, "open" is populated with several items, including the path. Now I would like to load the file into a filestream (or something similar) to be sent via a webservice... is this possible? thanks ...

StreamSource problem with FileInputStream vs File

SAX error if StreamSource(FileInputStream) but StreamSource(File) ok Hi, I encountered a StreamSource issue when the parameter was FileInputStream. When the parameter was File, it's ok. public int initXSD (String xsdFile) { // no error at all if File Source schemaFile = new StreamSource(new File(xsdFile)); // sax e...