filestream

C++: Read .txt contents and store into 2D array

我与影子孤独终老i 提交于 2019-12-22 01:15:13
问题 So me and my groupmates suddenly have some clutchwork at hand. I was assigned of making an import function that reads through a textfile that looks like this, and store it to a 2D array: The columns are Tab-separated. As this suddenly came up, dont have the entire project file with me and I am nowhere near my old reliables, I tried conjuring this up in the most generic way possible: void signal::import_data(string filename){ ifstream file; file.open(filename.c_str()); if(file.fail()){ cerr <<

Opening a File in C# using FileStream

荒凉一梦 提交于 2019-12-21 18:04:48
问题 I am trying to open a Binary file that I plan on converting to hex but I am running into issues with reading the file via FileStream, private void button1_Click(object sender, EventArgs e) { openFD.Title = "Insert a BIN file"; openFD.InitialDirectory = "C:"; // Chooses the default location to open the file openFD.FileName = " "; // Iniitalizes the File name openFD.Filter = "Binary File|*.bin|Text File|*.txt"; // FIlters the types of files allowed to by chosen if (openFD.ShowDialog() !=

Opening a File in C# using FileStream

爱⌒轻易说出口 提交于 2019-12-21 18:03:07
问题 I am trying to open a Binary file that I plan on converting to hex but I am running into issues with reading the file via FileStream, private void button1_Click(object sender, EventArgs e) { openFD.Title = "Insert a BIN file"; openFD.InitialDirectory = "C:"; // Chooses the default location to open the file openFD.FileName = " "; // Iniitalizes the File name openFD.Filter = "Binary File|*.bin|Text File|*.txt"; // FIlters the types of files allowed to by chosen if (openFD.ShowDialog() !=

how to force send_data to download the file in the browser?

核能气质少年 提交于 2019-12-21 17:28:23
问题 Well my problem is that I'm using send_data on my Rails 3 application to send to the user a file from AWS S3 service with something like Base.establish_connection!( :access_key_id => 'my_key', :secret_access_key => 'my_super_secret_key') s3File = S3Object.find dir+filename, "my_unique_bucket" send_data(open(s3File.url).read,:filename=>filename, :disposition => 'attachment') but seems like the browser is buffering the file and before buffering it sends the file to download taking no time on

Download pdf programmatically

狂风中的少年 提交于 2019-12-21 07:01:00
问题 How can I download a PDF and store to disk using vb.NET or C#? The URL (of the PDF) has some rediection going on before the final PDF is reached. I tried the below but the PDF seems corrupted when I attempt to open locally, Dim PdfFile As FileStream = File.OpenWrite(saveTo) Dim PdfStream As MemoryStream = GetFileStream(pdfURL) PdfStream.WriteTo(PdfFile) PdfStream.Flush() PdfStream.Close() PdfFile.Flush() PdfFile.Close() 回答1: You can try to use the WebClient (System.Net namespace) class to do

What's the difference between FileStream.Flush() and FileStream.Flush(True)?

北战南征 提交于 2019-12-21 06:50:27
问题 MSDN says that FileStream.Flush(True) "also clears all intermediate file buffers.". What does "all intermediate file buffers" mean exactly? 回答1: It causes the file data that's buffered in the file system cache to be written to disk. That data is normally lazily written, based on the position of the disk write head. Having a gigabyte of cached data is technically possible so it can take quite a while. If this is important to you then consider the FileOptions.WriteThrough option instead. It

OutOfMemoryException when using SQL Filestream

北城以北 提交于 2019-12-21 06:18:29
问题 I'm trying to upload a zip file which is around 600 MB to SQL 2008 FILESTREAM table and I get the OutOfMemoryException. I'm using the SqlFileStream class to upload the file (as described in this tutorial - http://www.aghausman.net/dotnet/saving-and-retrieving-file-using-filestream-sql-server-2008.html). I have a 32-bit Vista machine with 4GB ram if that matters and I'm using VS 2010, Entity Framework 4. Here's my code snippet - public static void AddItem(RepositoryFile repository) { var

FileStream not closing file

霸气de小男生 提交于 2019-12-21 04:21:28
问题 I have the following code: using (MemoryStream str = new MemoryStream()) { Program.api.GetDocument(result, str); using (FileStream fileStream = File.Create(filePath)) { str.WriteTo(fileStream); } } Whenever a file is written, it is always locked afterwards - attempting to delete it or modify it causes Windows to tell me the file is in use, even after closing my application. Am I missing something? 回答1: Your problem is most likely caused by Windows Search Indexing which is a part of Windows

Can Stream.CopyTo() method save the streams incomplete?

不羁岁月 提交于 2019-12-21 02:54:09
问题 I have a WCF service which allows me to upload files in chunks. What I am wondering is could this code can cause the uploaded stream to be only partially appended to the target stream in any case? I have my logs that shows me that all the sent streams are 512000 byte(which I set on client side) and I've sent 6 chunks out of 9 chunks so far. But on server the files size is 2634325. Which means the last chunk sent(6th) is saved incompletely. What can be causing this behaviour? What should I do

Can Stream.CopyTo() method save the streams incomplete?

不打扰是莪最后的温柔 提交于 2019-12-21 02:54:08
问题 I have a WCF service which allows me to upload files in chunks. What I am wondering is could this code can cause the uploaded stream to be only partially appended to the target stream in any case? I have my logs that shows me that all the sent streams are 512000 byte(which I set on client side) and I've sent 6 chunks out of 9 chunks so far. But on server the files size is 2634325. Which means the last chunk sent(6th) is saved incompletely. What can be causing this behaviour? What should I do