Questions tagged [filestream]

1

votes
2

answer
5.7k

Views

How to use filestream for copying files in c#

I want to copy a file from one folder to another folder using filestream.How this can be achived.when I try to use file.copy I was getting this file is using by another process, to avoid this I want to use file stream using c#. Can some one provide a sample for copying a file from one folder to anot...
N.RaviKumar
1

votes
1

answer
52

Views

How to read and write more then 25000 records/lines into text file at a time?

I am connecting my application with stock market live data provider using web socket. So when market is live and socket is open then it's giving me nearly 45000 lines in a minute. at a time I am deserializing it line by line and then write that line into text file and also reading text file and rem...
Hardik Dhankecha
4

votes
0

answer
37

Views

Why Stream.Copy is faster than Stream.Write to FileStream?

I have a question and I can't find a reason for it. I'm creating a custom archive file , I'm using Memory Streams to storing data and finally I use a file stream to write the data to disk. My Hard Disk is SSD , But the speed was too slow when I tried to write only 95MB to a file , It takes 12 second...
MikeTheCoder
1

votes
3

answer
5.1k

Views

Overwrite textfile when using file writer append in android

I want my app to create a folder in sd card and place the output text file there, for example : mnt/sdcard/myfolder/textfile_name. I've successfully implemented the method of getAbsolutePath, but I find a problem with the text file, if I write 5 lines in the first file then in the next file I write...
Raditya Kurnianto
1

votes
2

answer
727

Views

how to handle large xml files

public XmlNodeList GetNodes(string _logFilePath, string _strXPathQuery) { objXmlDoc = new XmlDocument(); objXmlDoc.Load(_logFilePath); XmlNodeList objxmlNodeList = objXmlDoc.SelectNodes(_strXPathQuery); return objxmlNodeList; } 999992013021110381000001 20130211103810 Message Flag Application Mod...
John
1

votes
2

answer
998

Views

find out how many bytes have been written to a filestream

I am using FileStream.Write() method for a server\client program. I am trying to find out if all the bytes have been written to the FileStream by using " int byteswritten = FileStream.Write(bytes1,0,bytes1.length);" I have noticed the FileStream.Read() method supports this feature but the FileStrea...
user2038443
1

votes
2

answer
666

Views

split a FileStream for multiple consumers in C#

I need to calculate MD5 checksum for many large files. The code for this is pretty simple: System.IO.FileStream file = new System.IO.FileStream(strFullPath, FileMode.Open); fsFile.Seek(1000, SeekOrigin.Begin); //skip some chars if need be System.Security.Cryptography.MD5 md5 = new System.Security...
Adam Luniewski
1

votes
1

answer
163

Views

FileStream ReadWrite in C#

I have a FileStream open as follows: FileInfo file = new FileInfo(@"C:\Project.xml"); FileStream stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); XmlDocument document = new XmlDocument(); document.Load(stream); The stream is opened when a project file is loaded. Now I need to...
Raheel Khan
1

votes
1

answer
642

Views

How can I use the DeflateStream class on one line in a file?

I have a file which contains plaintext mixed in with some compressed text, for example: Version 01 Maker SomeCompany l 73 mark h�22V0P���w�/�+Q0���L)�66□ // This line was compressed using DeflateZLib endmark It seems that Microsoft has a solution, the DeflateStream class, but t...
michael
1

votes
3

answer
70

Views

How to delete entry from file

try to delete some entry from csv file, if i know only part of string code //open File FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite); StreamReader sr = new StreamReader(fs); //divide file entry for separate lines string []line = sr.ReadToEnd().Split(new s...
gbk
1

votes
2

answer
409

Views

Build error while running

I am trying to run a code snippet multiple numbers of times in C#.Project name is test.Initial number of times it's running properly but after that i am getting the following build error."Error 1 Unable to copy file "obj\x86\Debug\test.exe" to "bin\Debug\test.exe". The process cannot access the file...
rampuriyaaa
1

votes
1

answer
11.8k

Views

VB.net Download HTML of a URL

Im in need of downloading the HTML generated by a server after sending a URL. I thought maybe the webclient.downloadfile would work but it seems like it gives up when you don't end the URL with a file extension. If I do have a webbrowser control set up that has navigated to a site on the same domain...
gNerb
1

votes
2

answer
2.3k

Views

Is there a workaround to enable FILESTREAM in the code first approach of entity framework

After much of googling I have come to three conclusion that until MVC 4 ( entity framework), that FILESTREAM (of Sql server) is not supported directly. Is there a work around for the same?
Moiz Tankiwala
1

votes
3

answer
780

Views

Need to close filestreams that were opened in another context of the same app

I have a main window on which a user clicks a button to process a selected input file. The block of code triggered by the button opens the input file, an output file, and a log file. That same block of code reads lines of the input file one at a time, does some operations on the fields in each line,...
user3076406
1

votes
1

answer
604

Views

Best way to read section of large file c#

Im working in .Net 2.0 mono for Unity3d deploying to handheld devices and desktop. I have to parse through large txt files on startup (currently using StreamReader). These may add up to 100/200MB or more even. Reading them into line arrays is fine on desktop but not on handheld devices. I need to ke...
user1711383
1

votes
2

answer
697

Views

MobileService table store picture

I want to save an image to my Azure MobileService. I have been looking around and found that you can use blob and azure storage. But instead of implementing this I would love if you could convert an image to string or stream that could be stored in a normal azure mobile service table. I am creating...
JTIM
1

votes
2

answer
959

Views

StringBuilder to FileStream vs. direct FileStream performance [closed]

I'm writing large amounts of text data to a FileStream incrementally, and it's rather slow. Would it be faster if I were to instead write the text to a StringBuilder in memory, and then dump the StringBuilder wholesale to the FileStream? I'm thinking that doing so might be able to take advantage of...
ekolis
1

votes
1

answer
2.7k

Views

How to add CRLF (Environment.NewLine) to FileStream correctly?

I'm combining multiple text files into a single text file in C# and I'm doing it in chunks using byte arrays... that part is working for me. But now I want to add a new line right before a new text file gets merged into my target text file. I've found on different threads that using the below code s...
sergeidave
1

votes
2

answer
79

Views

Is there any way to check file readability before trying to read it in FileSystemWatcher.Changed event?

I use FileSystemWatcher to monitor some folder for changes. When it fires file changed event, I need to read that file and update some stuff. The problem is that when this event is fired, target file is still forbidden to read even in this way FileStream fs = new FileStream(path, FileMode.Open, File...
Kosmos
1

votes
1

answer
11.1k

Views

How to write binary data into files in Java?

Is there a way to store some values in a binary file as C# does? For example in C# it would be: BinaryWriter bw = new BinaryWriter(MyFilStream); bw.Write(data...); And then, to read it like BinaryReader br = new bla bla...; br.ReadInt(file); Is there a way to do this in Java? I'm Reading a lot of bi...
Ramses Asmush
1

votes
1

answer
928

Views

How to read a very huge file from the end in C#? [duplicate]

This question already has an answer here: Read from a file starting at the end, similar to tail 4 answers I have a text file of size 4.5GB, which was created by one of the experimental applications. On my system of 8GB RAM, this file cannot be opened (tried with sublime text). I just want to read t...
MrClan
1

votes
1

answer
324

Views

extra spaces with string to buffer void type conversion implicit in Filestream.WriteBuffer method

Haven't needed to post here for a while, but I have a problem implementing filestreams. When writing a string to filestream, the resultnig text file has extra spaces inserted between each character So when running this method: Function TDBImportStructures.SaveIVDataToFile(const AMeasurementType: in...
Hamish_Fernsby
1

votes
2

answer
110

Views

Input with Streamreader doesn't give the same output in a StreamWriter

I'm reading a file with a StreamReader and writing the exact line to another file with a StreamWriter. The problem I have however is that in the resulting file any occurence of the character '¦' is converted to '?'. This is the code for initializing my streams: using (var readFile = new FileStream(...
Fedor Finkenflugel
1

votes
2

answer
2.7k

Views

“The process cannot access the file because it is being used by another process ”

I'm writing my application in C# using Windows Form. I'd like to execute CMD command, save result to textfile and then open this file in my program to parse and finally use values what I need. Unfortunately, when I run it CMD write "The process cannot access the file because it is being used by ano...
Robert
1

votes
2

answer
523

Views

Operator * Not Defined for types char and string

I added two vb files to a new vs project and I seem to be having a problem with the last line of the code below. I get an error: Operator '*' is not defined for types 'Char' and 'String'. I don't know too much about vb so can someone explain to me whats going on in this last line and how I may fix...
roadmaster
1

votes
1

answer
2.4k

Views

Download zip file from the server and parsing it

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 static void Main(string[] args) { string filePath = "C:...
rampuriyaaa
1

votes
1

answer
660

Views

Reading from a text file to populate an array

The goal I am going for is to store values into a text file, and then populate an array from reading a text file. At the moment, I store values into a text file; Pentagon.CalculateVertices();//caculates the vertices of a pentagon ofstream myfile; myfile.open("vertices.txt"); for (int i = 0; i < 5; i...
Moynul
1

votes
1

answer
569

Views

Filestream.write does not work

I used the following code to write on *.txt file, but nothing happens. Even, there is no exception. FileStream fs = new FileStream(@"D:\file.txt",FileMode.OpenOrCreate,FileAccess.Write,FileShare.None); //Creating a stream with certain features to a file StreamWriter writer = new StreamWriter(fs);...
Salman Lashkarara
1

votes
1

answer
74

Views

Json format broke after saving

So I have an application with a List. I store this List in a json file and while the application is running I make changes to the list and save it as .json file on disk. Before the application is closed by the user I would like to reset some values. On that save right before the application is close...
Florian Schaal
1

votes
2

answer
598

Views

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

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 to upload. It's onl...
wodzu
1

votes
3

answer
79

Views

How can i access a js file in my project?

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.
Penguen
1

votes
2

answer
709

Views

FileStream and it's buffering strategy

I've found out that there is no point in using BufferedStream in conjunction with FileStream as it has it's own buffering strategy. Yet, I was wondering about one thing: FileStream fsWithBuffer = new FileStream("buf.dat", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 255); fsWithBuffe...
Paweł Poręba
1

votes
2

answer
4.4k

Views

Could not find a part of the path C#

My application in winforms c# and my form need to retrieve the image from database and store in the local machine (Where my application is installed) and viewed in the PictureBox control. I have the following code (To store image locally and to view in PictureBox control): //dsProjects is a dataset...
Peter
1

votes
2

answer
1.1k

Views

Android- Saving File (Input & Output Stream) throws Exception (open failed: EINVAL (Invalid argument)) in Pre-lollipop devices

Android- Saving File (Input & Output Stream) throws Exception (open failed: EINVAL (Invalid argument)) in Pre-lollipop devices I am downloading a file from URL (www.xyz.in/file/9) and saving in SD CARD. Folder created code: try { //String folder_name = "NewFolder"; File f = new File(Environment.g...
Venkatesh Selvam
1

votes
1

answer
986

Views

PDFSharp download file thru filestream

I am new to this library but I couldn't find anything about downloading to the filestream with this library, I could only find a document.Save(filepath) option which is not always allowed. I would like to create a filestream so the file gets downloaded to the directed Downloads folder. Could someone...
Jean-Paul
1

votes
2

answer
48

Views

Get FileStream size (sql server) by mvc app context asp net mvc

I would like if .net (asp.net mvc) provides possibility to get size of FileStream having DbContext. As I did research so far I can: 1) SELECT SUM(DATALENGTH('ColumnName'))FROM Table 2) SELECT DB_NAME() AS [DBNAME], size / 128 AS [Size in MB] FROM sys.database_files WHERE type = 2; My question is i...
Cenarius
1

votes
2

answer
990

Views

Java Best Practices - Need to write to file constantly - BufferedWriter?

So I have a java process that needs to constantly append a new line to a file every 100 milliseconds. I am currently use BufferedWriter for this, but from what I have read, the BufferedWriter object should always be .close()'d when its finished. If I did this, I would have to create a new BufferedWr...
mathmonkey
1

votes
2

answer
49

Views

Any possiblilities that objects may be disposed earlier?

Is there any chance that fileStream object will likely be destroyed before its call to the Close method as below? FileStream fileStream = new FileStream(xxx); StreamReader txtReader = new StreamReader(fileStream); curLog = txtReader.ReadToEnd(); txtReader.Close(); fileStream.Close();
user3462253
9

votes
1

answer
2.7k

Views

Synchronization requirements for FileStream.(Begin/End)(Read/Write)

Is the following pattern of multi-threaded calls acceptable to a .Net FileStream? Several threads calling a method like this: ulong offset = whatever; // different for each thread byte[] buffer = new byte[8192]; object state = someState; // unique for each call, hence also for each thread lock(theFi...
Doug McClean
2

votes
1

answer
585

Views

SQL Server 2008 FILESTREAM Progress Indicator

I have a SQL Server 2008 database with a table that contains a FILESTREAM varbinary(max) column. I have set up the database server to use file streaming and everything works well. I have also created a client application using C# + Entity Framework 4.1 (Visual Studio 2010)—this too works well an...
HydroPowerDeveloper

View additional questions