file

how to search for file's has a known file extension like .py ??

how to search for file's has a known file extension like .py ?? fext = raw_input("Put file extension to search: ") dir = raw_input("Dir to search in: ") ##Search for the file and get the right one's ...

Easy - Read a file into a array

So I have a .dat file that just holds a list of names, each name is on a new line. I am having a day of complete mental blanks but how would I go about getting those names out of the file and puting them into a array. Thanks for any help ...

How to find multiple words on the same line in Notepad++

I have a 4MB log file from the Windows XP firewall which I'm trying to find lines that have both DROP and an IP and a port number. My regex-fu is weak and I'm assuming this is the reason I'm struggling. The words "DROP", "10.1.1.1" (for example) and "8801" need to be found on the same line and may be spread across the line and separated...

rename files with the same name

Hi. I use the following function to rename thumbnails. For example, if I upload a file called "image.png" to an upload folder, and this folder already has a file named "image.png" in it, the new file automatically gets renamed to "image-copy-1.png". If there also is a file called "image-copy-1.png" it gets renamed to "image-copy-2.png" a...

In java can i have more than one class/object in a file?

So the way i've been told to do things is you have your file and the file name is Classname.java and then the code is something like this: class ClassName { SOME METHODS main {} } and then thats all. I'd like to have two objects defined and used within the same .java file. (i don't want to have to put the other class in a difern...

How to create own filetype?

Hello, I want to create own filetype to save objects in my app. Basically, I urgently do not need new filetype, but it will be better. I have class. For example Car. It has constructor (String name, String color, int length, Driver driver). When a car is created (its instance), how to save it like a file? ...

Silverlight 4.0: How to determine the file size of an object in MemoryStream

byte[] imageBytes = Convert.FromBase64String(base64String); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); How will I determine its file size of an image? ...

How to check which files I fopen'ed on Windows?

I received a "Too many open files" error when tried to do fopen (C++, Windows XP). Probably it happened because somewhere in my program I open files without closing them. Is there a way on Windows to see a list of all open file descriptors (or all files that my program fopened)? ...

Can "\Device\NamedPipe\\Win32Pipes" handles cause "Too many open files" error?

Continuing from this question: When I am trying to do fopen on Windows, I get a "Too many open files" error. I tried to analyze, how many open files I have, and seems like not too much. But when I executed Process Explorer, I noticed that I have many open handles with similar names: "\Device\NamedPipe\Win32Pipes.00000590.000000e2", "\...

System.IO.File.ReadAllText(path) does not read the html file.

I want to read the html file.And for that I use System.IO.File.ReadAllText(path).It can read all the html file but there is one file which is not read through this function. I have also used using (StreamReader reader = File.OpenText(fileName)) { text = reader.ReadToEnd(); But still there is same problem. What is the reason can b...

How to create and update spreadsheet using OLEDB in C#?

HI! all I am creating .xls spreadsheet file using following code using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\temp.xls;Extended Properties='Excel 8.0;HDR=Yes'")) { conn.Open(); OleDbCommand cmd = new OleDbCommand("CREATE TABLE [NewSheet] ([Column1] string, [Column2] string)...

C/C++ full file path in assert macro

hello, I am wondering if it's possible to display full file path using the assert macro? I cannot specify full file path in compilation command, is there still a way to do it? My debug environment is linux/g++ ...

FileSystem.GetFiles() + UnauthorizedAccessException error?

Hello, It seems like FileSystem.GetFiles() is unable to recover from the UnauthorizedAccessException exception that .Net triggers when trying to access an off-limit directory. In this case, does it mean this class/method isn't useful when scanning a whole drive and I should use some other solution (in which case: Which one?)? Here's s...

JFileChooser - multiple file filters?

Hi guys, I have a question about the JFileChooser in Swing. I'm trying to get multiple file extensions in the drop-down box, but have no idea how to do it. There is the method extFilter = FileNameExtensionFilter(description, extensions); that I can then use by writing fileChooser.setFileFilter(extFilter); however, as you can see,...

How to delete a file with javascript?

Did not have luck with these examples: Javascript File remove Javascript FSO DeleteFile Method Deleting a File There are no special permissions on the file. Is there a way to do this in JQuery? The requirement is - a certain file must be deleted from the web directory when another page is loaded. There is no security issue as this ...

Can VBScript determine the most recently modified (or added) file in a particular folder?

Hello, I have a script (or more accurately WILL have a script) that checks a folder and copies a file from this folder to a different location (will run once per day). The fileName that I'd like to copy from, however, changes based on the date. Basically, instead of setting the "strFilePath" to "C:\somePath\somePath2\myFile.txt" I wou...

[PHP] Read and write to a file while keeping lock

Hi! I am making a simple page load counter by storing the current count in a file. This is how I want to do this: Lock the file (flock) Read the current count (fread) Increment it (++) Write new count (fwrite) Unlock file/close it (flock/fclose) Can this be done without losing the lock? As I understand it, the file can't be written...

How to save a picture to a file?

I'm trying to use a standard Intent that will take a picture, then allow approval or retake. Then I want to save the picture into a file. Here's the Intent I am using: Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE ); startActivityForResult( intent, 22 ); The documentation says: The caller may pass ...

Application configuration save to file or object serialization

Hi, I am working on a project and I need to save user configuration. The configuration is a set of Jchechboxes I need to store their state (true, false). Which do you think is the better way of saving it, in a file and if yes in what (ini, cfg, txt), or it is better to serialize the object with the states?? Or if there is another way, pl...

Writing a file to sdcard

I'm trying to write a file from an Http post reply to a file on the sdcard. Everything works fine until the byte array of data is retrieved. I've tried setting WRITE_EXTERNAL_STORAGE permission in the manifest and tried many different combinations of tutorials I found on the net. All I could find was using the openFileOutput("",MODE_WO...