filestream

SQL Server FileStream how to populate the filestream column

冷暖自知 提交于 2019-12-23 12:28:02
问题 I have come a across a few different methods for inserting data into SQL Server (For FileStream). What is the best method for inserting the FileStream objects? The main difference between the approaches below being one directly did the insert and the other put in a place holder for the FileStream object. One approach is that they were directly inserting the document via C# through an insert: Link: FileStream con.Open(); string sql = "INSERT INTO MyFsTable VALUES (@fData, @fName, default)";

StreamReader and Portable Class Library

天大地大妈咪最大 提交于 2019-12-23 07:19:31
问题 I am writing a ConfigManager class using Portable Class Libraries. PCL supports StreamReader and StreamWriter classes that I want to use, but the PCL version of those classes do not support passing in a string during construction. PCL also does not support the reader.Close() and writer.Close() . Lastly it doesn't support the FileStream class. So I am looking for an answer to any one of the following questions: How can I get the StreamReader and StreamWriter classes working in a PCL? How can I

How to stream an mp3 file using a temporary file?

我只是一个虾纸丫 提交于 2019-12-23 03:42:18
问题 I am working an Mp3 streamer. To stream mp3 file from url, I want to use a temporary file. But trying to read and write the same file throws IOException for File.ReadAllBytes because the file is in use. How can I get throught this problem? long pos = 0; string path = pathtothetempfile; MemoryStream ms = new MemoryStream(); FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); do { bytesRead = responseStream.Read(buffer, 0, buffer.Length); fs.Write

adding to azure blob storage with stream

社会主义新天地 提交于 2019-12-22 12:31:31
问题 I am trying to add an IFormFile received via a .net core web API to an azure blob storage. These are the properties I have set up: static internal CloudStorageAccount StorageAccount => new CloudStorageAccount(new StorageCredentials(AccountName, AccessKey, AccessKeyName), true); // Create a blob client. static internal CloudBlobClient BlobClient => StorageAccount.CreateCloudBlobClient(); // Get a reference to a container static internal CloudBlobContainer Container(string ContainerName) =>

Binary Reader and Writer open at same time?

匆匆过客 提交于 2019-12-22 09:00:10
问题 I'm writing code that deals with a file that uses hashes. I need to read a chunk, then hash it, then write it, then read another chunk, etc. In other words, I need to do a lot of reading and writing. I'm sure this is really simple, but I just wanted to run it by the pros... Is it possible, and acceptable to do something like: BinaryReader br = new BinaryReader (File.OpenRead(path)); BinaryWriter bw = new BinaryWriter (File.OpenWrite(path)); br.dostuff(); bw.dostuff(); I remember running into

How to complete remove filestream and all attached files

℡╲_俬逩灬. 提交于 2019-12-22 06:57:08
问题 I have tried the FILESTREAM feature for MSSQL (2008R2 Data Center) on a local database, to experiment. The real database is running on a server. I have setup the whole FILESTREAM, using this query: /* CREATE FILESTREAM AND FILESTREAM TABLE */ USE [master] GO ALTER DATABASE SenONew ADD FILEGROUP [FileStream] CONTAINS FILESTREAM GO ALTER DATABASE SenONew ADD FILE ( NAME = 'fsSenONew', FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\SenONew.ndf' ) TO FILEGROUP

storing images in sql server

烈酒焚心 提交于 2019-12-22 05:57:18
问题 I am trying to put together db design for storing images. Many of you might have had experience designing db to store images and the challenges associated with it. The db might store hundreds of thousands of images eventually. I am planning to use SQL Server 2008 db and entity framework. Planning to use FILESTREAM datatype for storing images. Following is the list of attributes i have considered storing for every image in db. Image Name, Image Type, Image Width, Image Height, Image Horizontal

Loading Image to Filestream

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 04:17:24
问题 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 回答1: You can open the file with FileStream: FileStream file = new FileStream("path to file", FileMode.Open); You can then pass this through to the web service http context Response.OutputStream property. You

Create and write to a text file inmemory and convert to byte array in one go

非 Y 不嫁゛ 提交于 2019-12-22 01:56:25
问题 How can I create a .csv file implicitly/automatically by using the correct method, add text to that file existing in memory and then convert to in memory data to a byte array? string path = @"C:\test.txt"; File.WriteAllLines(path, GetLines()); byte[] bytes = System.IO.File.ReadAllBytes(path); With that approach I create a file always (good), write into it (good) then close it (bad) then open the file again from a path and read it from the hard disc (bad) How can I improve that? UPDATE One

FILESTREAM files being left behind after row deleted

最后都变了- 提交于 2019-12-22 01:26:31
问题 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 managed directory with a uniqueidentifer as the filename not the original file added to the dbase. Does anyone know if SQLServer will delete the file eventually? If there are a lot of large files removed from the dbase I'd expect to be able to