filestream

how to send binary data within an xml string

。_饼干妹妹 提交于 2019-11-29 04:28:05
I want to send a binary file to .net c# component in the following xml format <BinaryFileString fileType='pdf'> <!--binary file data string here--> </BinaryFileString> In the called component I will use the above xml string and convert the binary string received within the BinaryFileString tag, into a file as specified by the filetype='' attribute. The file type could be doc/pdf/xls/rtf I have the code in the calling application to get out the bytes from the file to be sent. How do I prepare it to be sent with xml tags wrapped around it? I want the application to send out a string to the

Encode a FileStream to base64 with c#

折月煮酒 提交于 2019-11-29 02:53:35
I know how to encode / decode a simple string to / from base64 . But how would I do that if the data is already been written to a FileStream object. Let's say I have only access to the FileStream object not to the previously stored original data in it. How would I encode a FileStream to base64 before I flush the FileStream to a file. Ofc I could just open my file and encode / decode it after I have written the FileStream to the file, but I would like to do this all in one single step without doing two file operations one after another. The file could be larger and it would also take double

Encoding of Text Files in VB 6.0

我与影子孤独终老i 提交于 2019-11-29 02:37:39
I have huge external files with the "ANSI" and "UCS-2 Little Endian" encoding formats. Now I want to change the file encoding format into UTF-8 using Visual Basic 6.0. I don't want to modify the original file; I just want to change the encoding format alone. I have searched on the web; but can't understand the VB code, and have no idea how to do it. I would also like to be able to read lines one at a time from UTF-8 encoded files. Mark Bertenshaw NOTE. This answer has been extensively expanded to fit in with the edited question, which in turn was due to Visual Basic 6 and UTF-8 The following

Save Icon File To Hard Drive

百般思念 提交于 2019-11-29 02:06:52
I know that this must be incredibly easy - It's unbelievable how long I have searched for an answer to this question based on how simple it is in VB6. I simply want to extract an Icon from an EXE File using Icon.ExtractAssociatedIcon, and then save this icon file to my hard drive. So, here is what I have, and I will also show you what I have tried so you don't think I'm being lazy. OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); string s = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\IconData.ico"; Icon ico = Icon.ExtractAssociatedIcon(ofd.FileName); Bitmap

SQL Server PDF Full-Text Search not working on FileStream PDF File

*爱你&永不变心* 提交于 2019-11-28 23:52:35
I cannot get the Full-Text search to work on PDF files I am loading into my SQL Db via FileStream. Version: SQL Server 2008 R2 (Developer Edition - doing proof of concept) OS: Windows 7 Steps I have taken. Installed the Adobe iFilter Made sure SQL Server full Text Daemon service is running Added the environment path to the Adobe PDF Filter bin directory Ran the below scripts to setup the new iFilter and make sure it is active EXEC sp_fulltext_service @action='load_os_resources', @value=1; -- update os resources EXEC sp_fulltext_service 'verify_signature', 0 -- don't verify signatures EXEC sp

file stream vs local save in sql server?

北战南征 提交于 2019-11-28 23:51:17
my application play videos files after that user they are registered .(files are larger than 100 MB ) . Is it better to do I store them on the hard drive and Keep file path in database ? Or do I store in database as File Stream Type ? When data is stored in the database, are more secure against manipulation vs with stored in hard ? How to provide data security against manipulation ? Thanks . There's a really good paper by Microsoft Research called To Blob or Not To Blob . Their conclusion after a large number of performance tests and analysis is this: if your pictures or document are typically

Convert a Stream to a FileStream in C#

☆樱花仙子☆ 提交于 2019-11-28 23:31:46
What is the best method to convert a Stream to a FileStream using C#. The function I am working on has a Stream passed to it containing uploaded data, and I need to be able to perform stream.Read(), stream.Seek() methods which are methods of the FileStream type. A simple cast does not work, so I'm asking here for help. Read and Seek are methods on the Stream type, not just FileStream . It's just that not every stream supports them. (Personally I prefer using the Position property over calling Seek , but they boil down to the same thing.) If you would prefer having the data in memory over

SQL Server FILESTREAM limitation

点点圈 提交于 2019-11-28 23:30:16
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 be a limitation "FILESTREAM data can be stored only on local disk volumes" for the FILESTREAM attribute. If i anticipate my web app to store 200,000 images of 1-2mb each, i would require around 200gb of hard drive space to store the images. Since, the FILESTREAM requires all data to be stored only on local disk as per the limitation, it would be

FileStream and creating folders

白昼怎懂夜的黑 提交于 2019-11-28 21:00:37
Just a quick question. I'm using something like this FileStream fs = new FileStream(fileName, FileMode.Create); I was wondering whether there was a parameter I could pass to it to force it to create the folder if it doesn't exist. At the moment an exception is throw if folder isn't found. If there is a better method then using FileStream I'm open to ideas. Use Directory.CreateDirectory : Directory.CreateDirectory Method (String) Creates all directories and subdirectories as specified by path. Example: string fileName = @"C:\Users\SomeUser\My Documents\Foo\Bar\Baz\text1.txt"; Directory

C# Download big file from Server with less memory consumption

送分小仙女□ 提交于 2019-11-28 20:57:25
I have a big file of memory size 42 mb. I want to download the file with less memory consumption. Controller Code public ActionResult Download() { var filePath = "file path in server"; FileInfo file = new FileInfo(filePath); Response.ContentType = "application/zip"; Response.AppendHeader("Content-Disposition", "attachment; filename=folder.zip"); Response.TransmitFile(file.FullName); Response.End(); } alernative method tried with Stream public ActionResult Download() { string failure = string.Empty; Stream stream = null; int bytesToRead = 10000; long LengthToRead; try { var path = "file path