FAQ Database Discussion Community


Stream or buffer big files in WCF [closed]

c#,.net,wcf,filestream
I want to transfer big files via WCF tcp protocol, but I don't know which technique I should use: buffering or streaming. I want to transfer files asynchronously and show the progress in a progress-bar control. Streaming looks better, because I have no idea how to organize buffer in 4...

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

c#,stream,async-await,filestream,c#-5.0
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 similar question was asked here and here regarding the old BeginRead function. The...

To download and convert csv file to Datatable

c#,.net,filestream
I have a requirement where i need to download a csv file from given url and then export the data from file to database. Is there any way to download and convert the file directly to datatable rather than saving it to harddisk and then reading it to datatable. Hope...

File splitter method goes wrong when working with decimals

.net,vb.net,file,byte,filestream
I'm trying to develop a file-splitter method that splits a file into chunks of the desired size, it works perfect for files that has even filesize values (eg: if filesize is 2097152 bytes and I want to split it into two chunks, first chunk is 1048576 bytes and second chunk...

“main” java.lang.ArrayIndexOutOfBoundsException: 3 [duplicate]

java,csv,stream,filestream,opencsv
This question already has an answer here: What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? 9 answers i want to extract a particular single column value of CSV file.so i had used dataset of CSV FILE having Instances:45211 and Number of Attributes:17. i had try with this...

Error hanlder for FileStream - AS3 AIR

actionscript-3,flash,air,filestream
I'm saving an object to a file using FileStream. The object I'm saving has variables in it: var saveObj:Object = new Object() saveObj['FirstName']="Georges" saveObj['LastName']="St-Pierre" MY question is this: How do I make an error handler for a variable missing when I load the File? For example 'Firstname' is missing. How...

FileStream or WebClient - C#

c#,webclient,filestream
I'm currently generating some preview with the Wopi and the Office Web App technologies from Microsoft, and i'm having an issue. Sorry for my bad english, but i'll try to express myself as well as possible. So ! I'm generating the preview by downloading a file's content and storing it...

Read streamfile in java

java,file,csv,filestream,filereader
I am working on comma separated value file.i want to extract first position["0" place in array] value from each raw and want to some math calculation on it. csv inputfile is like this a,b,c,d 12,32,45,76 23,45,77,56 32,34,49,28 73,92,26,68 73,36,77,26 for getting first position it give me error like this Exception...

C++: Input file (data of unknown size) into vector issue

c++,vector,filestream,ifstream
I'm trying to put a file with two columns of data, x and y, into two vectors, one only containing x and the other only containing y. No column headers. Like this: x1 y1 x2 y2 x3 y3 However, when I run this code, I encounter an error: (lldb) Can...

Is it safe to use FileStream.seek in this way?

c#,.net,filestream,seek
Suppose I have a file format which is composed of a series of objects, where each object has a header of the following format: public struct FileObjectHeader { //The type of the object (not important for this question, but it exists) public byte TypeID; //The length of the object's data,...

Example of Why stream::good is Wrong?

c++,file-io,stream,filestream
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 << bar << endl; } I was immediately pointed here and told...

Character digit not true when read from UTF-8 file

java,utf-8,filestream,chars
So im using a scanner to read a file. However i dont understand that if the file is a UTF-8 file, and the current line being read when iterating over the file, is containing a digit, the method Character.isDigit(line.charAt(0)) returns false. However if the file is not a UTF-8 file...

How to run npm 'filestream' example code?

javascript,node.js,npm,filestream
I'm planning to use file stream api in the browser. By searching, I found this filestream module. https://github.com/DamonOehlman/filestream The author wrote a example usage code. Here it is. (File name : drag-n-drop.js) var crel = require('crel'); var detect = require('feature/detect'); var dnd = require('drag-and-drop-files'); var img = crel('img'); var video...

Combine multiple file streams into a single file?

c#,.net,filestream,binary-serialization
I have an application where I am persisting a large amount of binary data fairly quickly. I currently have two different data channels that can grow in size independently, so I store this using two files. However, these two files are closely coupled to each other (ID references that only...

how to write CSV FILE after modification in specific numeric column values using java

java,csv,filestream,export-to-csv,opencsv
i have a dataset csv file having around 46000 instance and 17 attributes.. then i extract on of the column values and modify its value by incremented by 1 now i want csv file with modified values.how can i get.... import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger;...

Passing subsequence of a stream without copying its content into a new instance

c#,stream,filestream
Let's assume I have following method: void Upload(Stream stream) { // uploads the content of the specified stream somewhere } And let's further assume I got some binary file f, which contains some data I'd like to upload with the method above. But: It's not the whole file I want...

Coutinued output in file at each run

c++,filestream
How to avoid updating the file content at each run #include <iostream> #include <fstream> #include <math> using namespace std; int main() { ofstream file("file.txt"); v2 = rand() % 100 + 1; file<< v2; file.close(); return 0 ; } I am looking to add a new line at each run containing...

Writing stream to file crashes on Xamarin iOS8

ios8,xamarin,filestream
I am creating a HttpWebRequest to download a file. HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); Now on success, I get the response stream and try to write it file. Stream responseStream = myHttpWebRequest.GetResponseStream(); DirectoryInfo di = new DirectoryInfo(url); string documents = ""; if(UIDevice.CurrentDevice.CheckSystemVersion(8,0)) documents = NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User)[0].ToString(); else documents =...

Reading files in c# with filestream and streamreader

c#,byte,filestream,streamreader,readline
I have a file, which contains data, I want to read it as byte[] and divide into 3 blocks. First line might be read as string, then 2nd block, might be 1-3 length of lines and all left bytes as block 3. I was wondering, how can I get that...

XmlDoc throws the process cannot access the file from tome to time?

c#,.net,xml,filestream,xmldocument
I have the following code for writing XML file based on datacontracts public static void LogDataContractToFile(string XMLStringToLog, string filePathAndName) { //String documentPath = string.Empty; String xmlObject = string.Empty; FileInfo fileinfo; XmlDocumentFragment xmlDocumentFragment; XmlTextWriter xmlWriter; XmlDocument xmlDocument = null; lock (LogDataContractToFileLock) { filePathAndName = filePathAndName.ToLower(); while (_workingWithFile.Contains(filePathAndName)) Thread.Sleep(1000); _workingWithFile.Add(filePathAndName.ToLower());...

Run exe file from FileStream

c#,byte,.net-assembly,filestream
I'm trying to run an exe file through filestream , but nothing is happens when I call the command. My code: string filePath = AppDomain.CurrentDomain.BaseDirectory + "OUT\\WAMServer.exe"; // read the bytes from the application exe file FileStream fs = new FileStream(filePath, FileMode.Open); BinaryReader br = new BinaryReader(fs); byte[] bin =...

Download zip file from the server and parsing it

c#,file,filestream
I am trying to download a zipped file from the server and trying to show the content of each files in zipped folder to the view. I wrote a separate code where the file is on my laptop and I ran across each file and dislpayed the content such as...

Saving an image using FileStream sometimes results in corrupt files

c#,filestream,corruption,bitmapsource,jpegbitmapencoder
I have an application where by I take a picture and press a save button and save the image to the computer. This works fine the majority of the time. But I am seeing some of my users with corrupt images. These images are about the right number of bytes...

Writing a Stream with FileStream without a BOM?

c++-cli,filestream,byte-order-mark
Is there a way to write a Stream with FileStream without a BOM? What I am doing here is first converting an XmlNode to a Stream and writing the stream to a file at some point later. I need it to be in the form of a Stream for it...

How can i access a js file in my project?

javascript,c#,c#-4.0,file-io,filestream
I want to read "script1.js" by filestream in my console application like below. But it returns to me an error. Is there any better way to read a js file in application, by using filestream it returns to me error: FileNotFound exception. ...

FileStream writing buffer to file

c#,filestream,streamwriter
I'm trying to upload a .srt file through an API that takes File as a parameter. The file is stored on the server, and I'm using FileStream and StreamWriter to write to it: string path = Server.MapPath("~/App_Data/captions/" + entryId) + ".srt"; FileStream f = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter s...

File comparison in VB.Net

vb.net,comparison,filestream
I need to know if two files are identical. At first I compared file sizes and creation timestamps, but that's not reliable enough. I have come up with the following code, that seems to work, but I'm hoping that someone has a better, easier or faster way of doing it....

modify and generate new csv file by extracting column values

java,file,csv,filestream,opencsv
I want to modify on column values of csv file with large dataset. so I had extracted on single column values(here 2nd) then find standard deviation by 2 time iteration of while loop.1st for find mean and 2nd for find standard deviation. standard deviation is multiply with extracted value and...

How to start from arbitrary index (offset) in cryptoStream readByte()

c#,encryption,filestream,cryptostream
I'm using the code bellow to Encrypt and Decrypt a file: // Encryption UnicodeEncoding UE = new UnicodeEncoding(); byte[] key = UE.GetBytes("password"); FileStream fsCrypt = new FileStream("cryptFile", FileMode,create); RijndaelManaged RMCrypto = new RijndaelManaged(); CryptoStream cs = new CryptoStream(fsCrypt, RMCrypto.CreateEncryptor(key, key), CryptoStreamMode.Write); FileStream fsIn = new FileStream("FileName", FileMode.Open); int data; while...

Get only numbers from line in file

c#,filestream
So I have this file with a number that I want to use. This line is as follows: TimeAcquired=1433293042 I only want to use the number part, but not the part that explains what it is. So the output is: 1433293042 I just need the numbers. Is there any way...

Maximum size/offset of streamed File using Ada.Streams.Stream_IO.Read

io,filestream,ada,gnat
I try to read specific blocks of Data (around 4096 bytes) from a (possibly) huge file. Using Ada.Streams.Stream_IO.Read() with the GNAT compiler, what would be the maximum offset that I could use? That is, if I wanted to read the last 4 kilobytes of the file, using type Block_Array is...

Attempted to seek before beginning of stream inside a using() statement

c#,filestream
So I got the IOException: Attempted to Seek before the beginning of the stream. But when I looked into it the seek statement was inside of a using statement. I might be missunderstanding the using() because as far as I knew this initializes the in this case filestream before running...

Reading from a textfile in a certain format

c,text-files,filestream
I am trying to read from file in this order: 0 0 4 (100) 12 (67) 2 this correspondes to: process id, arrival_time, 1st_CPU_burst, (1st_IO_burst), 2nd_CPU_burst, (2nd_IO_burst) This has something to do with operating system fundamentals I am trying to perform fcfs scheduling with a queue but before I do...

UnauthorizedAccessException on creating file after deletion using FileStream

.net,vb.net,multithreading,filestream,file-access
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...

open pdf from stream using pdfclown in c#

byte,filestream,pdfclown
I am really liking pdfclown in c# but I would like to open a pdf from a byte[] array or filestream. I have not found any examples of this for pdfclown. Could anyone help? An example would be something like: using (org.pdfclown.files.File file = new org.pdfclown.bytes.IInputStream(bytes)) { ... } Thanks...

Principles behind FileStreaming

c#,wcf,filestream
I've been working on a project recently that involves a lot of FileStreaming, something which I've not really touched on before. To try and better acquaint myself with the principles of such methods, I've written some code that (theoretically) downloads a file from one dir to another, and gone through...