file-io

File.exists() returns false when file exists

I've encountered a bug I can't seem to find any logic behind. I have this File object, which is created like this: File file = new File("utilities/data/someTextFile.txt"); I then do file.exists() and it returns false (!?). If the file is not found, I'm logging f.getAbsolutePath() to a file. When I look at the path, it seems OK. I can ...

logging and Flush in .net

I have a program that looks something like this: public partial class It { static StreamWriter logging = new StreamWriter(new FileStream(@"C:\log",FileMode.Create)); void someFn() { logging.WriteLine("foo"); logging.Flush(); /// killed here in debugger with Shift+F5 } } The problem it tha...

How can I convert a file to a ByteArray in Flex?

I was wondering how to convert a file I have on my server (pdf/excel/ppt) to a ByteArray. The reason I want to do this is to display the dialogue open/save as to the user and I must set the Content-Type to octet-stream. The dialogue shows fine with just navigateToURL() but for pdf's it is the user's local browser setting. For a URLReques...

Edit music metadata with c#

how can i access the summary of a file like music file (any format) and edit it and especially the artwork of this file(the photo that are included in the file) and edit it too? thanks. ...

How do I resolve a "print() on closed filehandle" error in Perl?

I am getting this error while executing my Perl script. Please, tell me how to rectify this error in Perl. print() on closed filehandle MYFILE This is the code that is giving the error: sub return_error { $DATA= "Sorry this page is corrently being updated...<p>"; $DATA.= "<A href=\"javascript:history.go(-1)\"> Back </A>"; ...

How do I make my program watch for file modification in C++?

There are a lot of programs, Visual Studio for instance, that can detect when an outside program modifies a file and then reload the file if the user wants chooses. Is there a relatively easy way to do this sort of thing in C++ (doesn't necessarily have to be platform independent)? ...

How do I load an image using SDL and Xcode on OS X 10.5?

Edit: After using a bmp at toastie's suggestion, I'm still having problems loading the image: I'm using SDL and OpenGL with Xcode and I'm trying to load an image to use as a texture on a cube. The image is a 256x256 RBG jpeg. The image is in the same directory as all of my source code, and it's under the Resources folder in the Xcode pr...

How do I provide ReadFileEx()'s completion routine with context information?

Win32 ReadFileEx is defined as: BOOL WINAPI ReadFileEx( __in HANDLE hFile, __out_opt LPVOID lpBuffer, __in DWORD nNumberOfBytesToRead, __inout LPOVERLAPPED lpOverlapped, __in_opt LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine ); I am trying to figure out how to make the completion routine (the last arg...

How do I read a text file on the same server with ASP.NET?

Solution: It turns out I wasn't checking the path that it was looking up, quite silly of me. Once I tracked that problem down and corrected the offending path, the reading worked just fine. Still baffled at the MSSQL issue, since the articles average less than 10 000 bytes. Clarification: I am unsure if some of you are under the imp...

Write to file that is open in Excel

Suppose I have a program running that periodically adds information to a .CSV file. Is there a way to write to the file while it is already open in Excel? Obviously the changes wouldn't be noticed until the file was re-opened in Excel, but as it stands right now, I'm catching IOException and just starting a new .csv file if the current...

Open File handle limit on Windows Mobile

How can I find out the maximum number of file handles that can be open at once on a windows mobile device? I am running a native C++ application on a windows mobile proffesional emulator and there seems to be a limit of 39 open file handles (strange number I know), where any other files I open after that returning the error code 5 (ERRO...

Fast Read/Write of Complex .Net Object Graph

Hi, I have my own data structure written in C# (the structure is quite complex). I need to serialize and deserialize the structure. The size of the serialized file in disk can be pretty large at times (close to a 1 GB) but it can be small also (based on the number of records stored). I have the following requirements: The serializatio...

Is it possible to check if a file stream is open in Rails?

I have f = File.new(contacts_file_path, "wb") f.write params[:uploaded_file].read f.close I want begin f = File.new(contacts_file_path, "wb") f.write params[:uploaded_file].read rescue #error ensure if f.open? then f.close end end But f.open? is not a function and I can't find any api documentation. Any ideas? ...

Why won't python allow me to delete files?

I've created a python script that gets a list of files from a text file and deletes them if they're empty. It correctly detects empty files but it doesn't want to delete them. It gives me: (32, 'The process cannot access the file because it is being used by another process') I've used two different tools to check whether the files a...

Is there any reason to open a file with shared-write access?

I've always opened my files two ways -- either read access and shared-read, or read/write access and no sharing. To me it seems that allowing shared-write could always result in unexpected things happening to the file while you're reading it. Are there any good reasons to open a file in shared-write mode? ...

Extracting QuickTime Files from a Resource and converting them into Separate Files (VB.NET 2005)

I have a resource file for a program, and i have determined that the resource file just a big string of files glued together whole, i know that the movies contained in the file are quicktime mov. Where can i find information on the quicktime header? and how can i determine the length of a file once i find it? ...

Able to Delete Open Image Files in .NET

Hi, I have a small utility that deletes files from folders using .NET's FileInfo.Delete() method. Basically, I can catch an IOException if the file is currently open. This works for all files except for image files (JPG, GIF, BMP, ect.). When these types of files are open, the program is still able to delete them without throwing any...

When will .net support long paths natively?

As many would have discovered .net does not handle long paths names well. So when will .net support long paths natively? By natively I mean with out any of the suggested workarounds like subst and pinvoke Some reading: http://blogs.msdn.com/bclteam/archive/2007/03/26/long-paths-in-net-part-2-of-3-long-path-workarounds-kim-hamilton.as...

Writing data to a restricted size text file in C

I need to write some system log data (usually not more than 100 characters at a time) into a log file based on particular events. But the size of this log file is small (say around 4KB), and I need to wrap around the logs when the file size hits the limit. While wrapping around, I need to preserve the latest info, and later on present it...

Trouble using ReadFile() to read a string from a text file

Hello everyone, How can I make the code below to read correct text. In my text file has Hello welcome to C++, however at the end of the text, it has a new line. With the code below, my readBuffer always contains extra characters. DWORD byteWritten; int fileSize = 0; //Use CreateFile to check if the file exists or not. HANDLE hFile =...