filestream

stop hashing operation using filestream

吃可爱长大的小学妹 提交于 2019-12-13 02:12:41
问题 I'm having this piece of code that computes the MD5 hash for a given input file. public static String ComputeMD5(String filename) { using (var md5 = MD5.Create()) { try { using (var stream = File.OpenRead(filename)) { return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower(); } } catch (Exception) { // File is not accessible, return String.Empty return String.Empty; } } } I'm running this time consuming operation in a separate thread. For very big files this operation

Streaming file from android to .net http service

拥有回忆 提交于 2019-12-13 01:01:04
问题 Im trying to stream a file from android to an asp.net service: private static void writeFile(File file, DataOutputStream out) throws IOException { BufferedInputStream bufferedFileIs = null; Base64OutputStream base64out = null; try { out.writeBytes("fileBase64="); base64out = new Base64OutputStream(out, Base64.DEFAULT); FileInputStream fileIs = new FileInputStream(file); bufferedFileIs = new BufferedInputStream(fileIs); int nextByte; while ((nextByte = bufferedFileIs.read()) != -1) { base64out

PHP Stream mp3 file

馋奶兔 提交于 2019-12-13 00:17:56
问题 i need to allow the user to stream it only no download for that file how can i do that ? another question this code i have problem the file get downloaded first then play ? <?php $file = isset($_GET['q']) ? dirname(__FILE__) . base64_decode($_GET['q']) : false; $file = urldecode(str_replace('/', '\\', $file)); $download = isset($_GET['d']) ? $_GET['d'] == 't' ? true : false : false; if ($file) { $disabelStr = 'DisableTrackDownload-'; $pattern = '/'.$disabelStr.'/'; $disableDownload = preg

reading bytes in a file in vb.net

…衆ロ難τιáo~ 提交于 2019-12-12 14:29:43
问题 After getting the file name I create a new filestream and load all the bytes from the FileStream into a byte array, now I need to get certain bytes and store them in fields like the second 4 bytes are the time the file was created. When storing these in the variables should I store them as bytes or as string/integers/etc. Or have I done it completely wrong? EDIT:Should I be doing this way instead of a filestream? Dim data() as Byte = File.ReadAllBytes(path1) 回答1: Using File.ReadAllBytes is a

filestream in sql server and C# for aspx

痞子三分冷 提交于 2019-12-12 13:09:52
问题 I am developing a website for educational domain. I want to store a document (MS Word or text file) in database in binary format using Filestream in SQL Server 2008. but I am unable to retrieve the document in a textbox. My code is as follows: string path = reader.GetString(0); SqlFileStream stream1 = new SqlFileStream(path, (byte[])reader.GetValue(1), FileAccess.Read, FileOptions.SequentialScan, 0); StreamReader fs = new StreamReader(stream1); fs = File.OpenText(path); string s = fs

Read the actual contents of text file using FileStream and these options c#

时光怂恿深爱的人放手 提交于 2019-12-12 10:28:44
问题 I need to open a text file within C# using FileStream and with the options mentioned below var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 64 * 1024, (FileOptions)FILE_FLAG_NO_BUFFERING | FileOptions.WriteThrough & FileOptions.SequentialScan); The text file contains a "1" or "0" and after obtaining the results I am going to assign the contents of the text file to a string variable. In case you're interested, I need the above options in order to avoid

File is being used by another process in c#

拈花ヽ惹草 提交于 2019-12-12 10:04:34
问题 I am trying to delete a file in C#, however I am receiving a message that the file is used from another process. What I want to do is to check if the files exists and close it. I am using the following function in order to check if the file is open: public static bool IsFileInUse(string path) { if (string.IsNullOrEmpty(path)) throw new ArgumentException("'path' cannot be null or empty.", "path"); try { using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { } } catch

C# - Parallelizing While Loop with StreamReader causing High CPU

限于喜欢 提交于 2019-12-12 10:02:42
问题 SemaphoreSlim sm = new SemaphoreSlim(10); using (FileStream fileStream = File.OpenRead("...")) using (StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8, true, 4096)) { String line; while ((line = streamReader.ReadLine()) != null) { sm.Wait(); new Thread(() => { doSomething(line); sm.Release(); }).Start(); } } MessageBox.Show("This should only show once doSomething() has done its LAST line."); So, I have an extremely large file that I want to execute code on every single

fulltext index returning no results from pdf filestream

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 09:47:07
问题 I have a filestream table running on SQL Server 2012 on a Windows 8.1 x64 machine, which already have a few PDF and TXT files stored, so I decided to create a fulltext index to search through these files by using the following command: CREATE FULLTEXT CATALOG FileStreamFTSCatalog AS DEFAULT; CREATE FULLTEXT INDEX ON storage (FileName Language 1046, File TYPE COLUMN FileExtension Language 1046) KEY INDEX PK__storage__3214EC077DADCE3C ON FileStreamFTSCatalog WITH CHANGE_TRACKING AUTO; Then I

UnauthorizedAccessException on creating file after deletion using FileStream

孤街醉人 提交于 2019-12-12 09:24:53
问题 I am facing an issue on client system. On trying to reproduce it in a sample code I have reproduced it. Here's the sample code Imports System.IO Public Class Form1 Private _lock As New Object Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim t As New Threading.Thread(AddressOf createFile) With t .IsBackground = True .Name = Guid.NewGuid.ToString .Start() End With End Sub Private Sub createFile() Dim path As String = "D:\SomeFile