天道酬勤,学无止境

file

Is it possible to prevent file dialog from appearing? Why?

Suppose I have input[type=file] element and I want to intercept onclick event and prevent file dialog from appearing if conditions are not met. Is it possible? And why, if - not?

2021-06-15 16:26:19    分类:问答    html   file   input   event-handling   filedialog

Memory error reading a zip file in python

I have a thread in which I am reading a zip file with zipfile.ZipFile().read(), where I am getting a memory error. I am aware that read() loads the entire file into memory. The size of file after unzipping is more than 100MB. I also tried with zipfile.ZipFile().open().readlines(), but it takes too much time. Is there any way that I can read the file with speed without getting memory error?

2021-06-15 16:16:09    分类:问答    python   file   memory   zip

Can I access Resources file from a View in MVC?

I want to populate dropdownlist with values stored in a resource file. What's the best approach for this? I can create a SelectList and push it in Model in which case dropdown would be populated automatically. But can I access resource file from a View ? If yes, should I?

2021-06-15 15:50:54    分类:问答    asp.net-mvc   file   resources

NSDocumentDirectory files disappear in ios

I want to save a mp4 video in my folder but when I open again the app, this file is nil. But when I save the file, I can open it, so it seems that it disappears from the folder. Save: NSData *videoData = [NSData dataWithContentsOfURL:exportUrl]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/%@",videoName]; self.path_video_to_save = tempPath; BOOL success = [videoData writeToFile:tempPath atomically:YES]; if (success)

2021-06-15 15:22:09    分类:问答    ios   file   ios8   nsdocumentdirectory

Rename all files in folder to uppercase with batch

Is there a way to rename all files in a specific folder to uppercase with batch file? I found this code. But it renames files to lowercase. How to modify it to rename to uppercase instead? for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")

2021-06-15 13:36:14    分类:问答    file   batch-file   file-management

DirectoryInfo.GetFiles, How to get different types of files in C#

How can I find both file types *.gif and *.jpg using DirectoryInfo.GetFiles function in C# ? When I try this code: string pattern = "*.gif|*.jpg"; FileInfo[] files = dir.GetFiles(pattern); The exception "Illegal characters in path." is thrown.

2021-06-15 13:33:26    分类:问答    c#   file   search   filter   directory

C Delete last n characters from file

I need to delete the last n characters from a file using C code. At fist I was trying to use '\b', but it returns a Segmentation Fault. I have seen interesting answers to similar questions here and here, but I would prefer to use mmap function to do this, if it's possible. I know it could be simpler to truncate the file by creating a temp file, and writing chars to temp until some offset of the original file. The problem is I don't seem to understand how to use mmap function to do this, can't see what parameters I need to pass to that function, specially address, length and offset. From what I

2021-06-15 13:21:08    分类:问答    c   file   char   truncate   mmap

How to download a zip file from a site (python) [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago. There is a site with logs and each log is in zip (for space saving). How can I download it from the site? ( urllib / urllib2 )(?)

2021-06-15 13:14:23    分类:问答    python   file   download   zip

How to use a Batch-File to Rename a File to Include the Date?

I've got a text file that displays an alarm printer. I would like to set up a batch file, under Windows XP, to change the default name of the alarm printer to include the date, which would make searching for errors much easier. The alarm printer is captured to a text file. I've been able to change the name, but every time I try to set the name to the date either nothing happens or the name is changed to the code instead. So far I've tried for /f "tokens=1-5 delims=/ "%d in (%date%) do rename "C:\TPM 4 Alarm Printer\test.txt" %%e-%%f-%%g.txt and for /F "tokens=2,3,4 delims=/ " %%i in ('date/t')

2021-06-15 12:58:15    分类:问答    windows   file   batch-file

Python File Creation Date & Rename - Request for Critique

Scenario: When I photograph an object, I take multiple images, from several angles. Multiplied by the number of objects I "shoot", I can generate a large number of images. Problem: Camera generates images identified as, 'DSCN100001', 'DSCN100002", etc. Cryptic. I put together a script that will prompt for directory specification (Windows), as well as a "Prefix". The script reads the file's creation date and time, and rename the file accordingly. The prefix will be added to the front of the file name. So, 'DSCN100002.jpg' can become "FatMonkey 20110721 17:51:02". The time detail is important to

2021-06-15 12:29:07    分类:问答    python   file   date   rename   creation