I have two different modules that need access to a single file (One will have ReadWrite Access - Other only Read). The file is opened using the following code in one of the modules:
FileStream fs1 = new FileStream(@"D:\post.xml", FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
Th problem is that the second module fails while try...
I have a ASP.NET SOAP web service whose web method creates a PDF file, writes it to the "Download" directory of the applicaton, and returns the URL to the user. Code:
//Create the map images (MapPrinter) and insert them on the PDF (PagePrinter).
MemoryStream mstream = null;
FileStream fs = null;
try
{
//Create the memorystream stor...
My problem is quite simple: I have a 400MB file filled with 10,000,000 lines of data. I need to iterate over each line, do something, and remove the line from memory to avoid filling-up too much RAM.
Since my machine has several processor, my initial idea to optimize this process was to create two different processes. One would read the...
Do I need to malloc when creating a file to write to?
The file will be based on the contents of 2 others, so would I need to malloc space for the writeable file of sizeof( file a ) + sizeof( file b) + 1?
Sorry if this makes no sense; if it doesn't then I guess I need to go read some more :D
Essentially, I have 2 txt files and a stri...
I have an application where there are multiple processes. They share the reading and writing of a set of files that grows over time. I'd rather not expose thousands of files to the user's environment, where it would be much easier for them to accidentally modify or delete one of them. Is there an API that will allow reasonably high perfo...
Hi - I'm trying to read an image file and scale it by multiplying each byte by a scale its pixel levels by some absolute factor. I'm not sure I'm doing it right, though -
void scale_file(char *infile, char *outfile, float scale)
{
// open files for reading
FILE *infile_p = fopen(infile, 'r');
FILE *outfile_p = fopen(outfile...
I have a directory with around 15-30 thousand files. I need to just pull the oldest one. In other words the one that was created first. Is there a quick way to do this using C#, other than loading them into a collection then sorting?
...
When i try to open a file in write mode with the following code:
packetFile = open("%s/%s/%s/%s.mol2" % ("dir", "dir2", "dir3", "some_file"), "w")
Gives me the following error:
IOError: [Errno 2] No such file or directory: 'dir/dir2/dir3/some_file.mol2'
Note that the "dir/dir2/dir3/" does exist!
Also the "w" mode should create the fi...
I'm having an issue opening files that have recently been closed by the .Net framework. Basically, what happens is the following:
Read in an XML file using DataSet.ReadXml()
Make some changes to the data
Write out the XML file using DataSet.WriteXml()
Copy the XML file to a new location using File.Copy
FTP the file using a cus...
Given the path of a file (e.g. "C:\MyPicture.jpg"), how do I convert a binary file into a byte array?
I know I have a lot of .NET objects at my disposal, such as BinaryReader, FileStream, StreamReader, and others, but I'm not sure of the best method to take a binary file and convert it into byte[]. How might this be accomplished?
...
When I attempt to open a file to write to I get an Ada.IO_Exceptions.Name_Error.
The file name is "C:\CC_TEST_LOG.TXT". This file does not exist.
This is on Windows XP on an NTFS partition. The user has permissions to create and write to the directory.
The filename is well under the WIN32 max path length.
name_2 : String := "C:\CC_TE...
There's been a discussion between me and some colleagues that are taking the same class as me (and thus have the same project) about saving data to files and read from those files only when we need that specific data.
For instance, the project is something about managing a social network. I'm not going into specifics because it doesn't ...
Hello everybody, I am currently developing an application, which gets the input from a text file and proceeds accordingly. The concept is the input file will have details in this fomat
A AND B
B OR C
Each and every line will be seperated by a blank space and the input must be taken from the text file and processed by logic....
I am using File IO, to save a file in local system(i.e PC C: drive), URL to save is like this "C:\htmlfiles\".$name_of_file.".html" the "\" in the string "C:\htmlfiles\" is giving the problem, tell me how to escape the '\'. please help.
...
Hi,
We're switching to commons for our file IO.
But when i try to write a string to a file where the directory doesn't exist it gets a FNF exception. Pretty right you think.
Javadoc says:
public static void writeStringToFile(File file,
String data,
String encod...
What is the difference in functionality between StreamWriter.Flush() and StreamWriter.Close()?
When my data wasn't being written correctly to a file, I added both Flush() and Close() to the end of my code. However, I realized that adding either Flush() or Close() allowed the data to be written correctly.
I wasn't able to pick up on ex...
The following code generates a FileNotFoundException (using .NET 2.0):
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LazyFileInfoTest
{
class Program
{
static void Main(string[] args)
{
File.WriteAllText("Test.txt", "Hello World!");
Directo...
I need to write just a function that counts the number of integers in an already opened and good text file.
a. Assume there is a text file with a large number of integers divided by spaces
b. Write a function called analyzeFile that accepts a previously opened ifstream
file object as a parameter, and counts the number of integers in th...
Hi,
I need to read a file from the local file system using JSP, save it as a string , and send it to a webservice(deployed using glassfish) for processing. Can anyone suggest how to perform File IO using JSP?
Thanks,
Deepak.
...
Is there a touch() function available? I would like to update the timestamp so my script doesnt delete the file when it becomes X old. Another issue is it should work when the file is locked for reading by another process.
...