file

Re-open files in Python?

Say I have this simple python script: file = open('C:\\some_text.txt') print file.readlines() print file.readlines() When it is run, the first print prints a list containing the text of the file, while the second print prints a blank list. Not completely unexpected I guess. But is there a way to 'wind back' the file so that I can read...

Use file_put_contents as Upload Function?

Can i also use file_put_contents($fileapp,$content,FILE_BINARY); to move uploaded files? ...

GWT - Fail to Read properties

When I run in hosted mode, it able to get the result. But when I deploy it to tomcat then I cant get the result at all. Anyone can tell me what is the problem?? public class Customwidget implements EntryPoint { private static final SystemConfig constants = (SystemConfig)GWT.create(SystemConfig.class); public void onModuleLoad() {...

iphone: How do you find the creation date of a file?

hi all. I'm trying to find the creation date (NOT modification date) of a file. Creation date doesn't appear to be in the attributes of a file, though modified date is. I'm using this code.. NSFileManager* fm = [NSFileManager defaultManager]; NSString* path = [PathHelpers pathInDocumentsFolderWithFilename:FILE_NAME]; NSDictionary* a...

Renaming a file on a remote file server in C# / Python

I need to rename a whole heap of files on a Windows file server - I don't mind what language I use really as long it's quick and easy! I know it's basic but just to clarify - in pseudo-code... server = login (fileserver, creds) foreach (file in server.navigateToDir(dir)) rename(file) I know how to do this in Python/C# if I was a...

Storing a large binary file

Hi, Are there any ways to store a large binary file like 50 MB in the ten files with 5 MB? thanks are there any special classes for doing this? ...

Determining Whether a Directory is Writeable

Hi Stackoverflow, What would be the best way in Python to determine whether a directory is writeable for the user executing the script? Since this will likely involve using the os module I should mention I'm running it under a *nix environment. ...

Getting modification date-time of a file with seconds in cmd.exe

I've created a batch which automatically uploads some files to FTP server, if they're modified. And modification is detected by changed file's modification time and size. But if the modification is made within the same minute, and file size did not change, modification stays undetected, and file is not uploaded. Is there a way to get exa...

How do I find the first 5 files in a directory with PHP?

How would I list the first 5 files or directories in directory sorted alphabetically with PHP? ...

type of file asp.net

hi, How we can know type of file in asp.net ? ...

including 1 file among 2 file?

I do apologize for asking this stupid question but I am wondering if you can help me.. i want insert among file $cat1 or $cat2 to in page.php... the code i was create e.g. <? //config.php $cat_all = ($cat2 or $cat1); $cat1 = "cat.php" ; $cat2 = "../back-up/cat.php"; //default anyway if(file_exists($cat1)){ require_once $cat1; }else...

I have a sybase database in a file. How do I determine for which version of sybase it is for?

Hello, I've been handed a file which appears to me to be a Sybase database file from some older Sybase version. I have d-loaded the latest sybase package from sybase and tried using that to connect to the contents but failed. Can someone suggest to me how to determine which version of sybase (and perhaps even which sybase db product) my...

Uploading a text box into a text file on an ftp C#

I am trying to stream a multiline textbox into a text file on an ftp server. Can someone tell me where I may be going wrong? private void btnSave_Click(object sender, EventArgs e) { UriBuilder b = new UriBuilder(); b.Host = "ftp.myserver.com"; b.UserName = "user"; b.Password = "pass"; b.Port = 21; b.Path = "/myse...

Python: file with programmer-defined attributes

Using Python 2.5, I'd like to create a temporary file, but add (& modify) attributes of my own. I've tried the following: class TempFileWithAttributes ( ) : __slots__ = [ '_tempFile' , 'Value' ] def __init__ ( self ) : self._tempFile = tempfile.TemporaryFile() object.__setattr__ ( self, '_tempFile', t...

Possible reasons for tellg() failing?

ifstream::tellg() is returning -13 for a certain file. Basically, I wrote a utility that analyzes some source code; I open all files alphabetically, I start with "Apple.cpp" and it works perfectly.. But when it gets to "Conversion.cpp", always on the same file, after reading one line successfully tellg() returns -13. The code in questi...

open() fails to open files

For some reason I can't get open() to open a file. Here's my code. static int context_ctor(X86Context *ctx) { char file[512]; memset(ctx, 0, sizeof(X86Context)); sprintf(file, "%s.%d", "test", getpid()); ctx->fp = open(file, O_RDWR); if(ctx->fp < 0) { printf("errno %d %s\n", errno, file); return VI...

Paramiko equvalent of pipline controls and input/output pipes

I need a method of paramiko based file transfer with a lightweight SSH2 server (dropbear) which has no support for SCP or SFTP. Is there a way of achieving a cat and redirect style file transfer, such as: ssh server "cat remote_file" > local_file with paramiko channels? Can paramiko.Transport.open_channel() or Message() do the job? I...

PNG, Why is visual studio making me download PNG files?

i write and my page loads it find. When i click on the link instead of having the image show on screen it promps me to download it. Why? How can i make it display in the browser? gif and jpg both display in the browser. -edit- i am using FireFox 3.5 there is no code that serves it, its just a link and the file exist in my folder. The l...

Text file lines into array with PHP

How would I put the lines of a text file into an array with PHP? Thanks. ...

How to determine if a file can be written using C++

In C++ how can I determine if the program has either read-only access or read-write access to a file? I searched the boost filesystem library but I have yet to find something to help me. Right now I thinking of opening the file, trying to write inside and check for error, but that doesn't seem a very appropriate way of doing this. Any c...