filenames

C# Filepath Recasing

≡放荡痞女 提交于 2019-12-18 11:45:18
问题 I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies. Example: string filepath = @"C:\temp.txt"; filepath = FileUtility.RecaseFilepath(filepath); // filepath = C:\Temp.TXT // Where the real fully qualified filepath in the NTFS volume is C:\Temp.TXT I've tried the following code below and many variants of it and it still doesn't work. I know Windows is case-insensitive in general but I need to pass

Python: existing file not found (IOError: [Errno 2]) when using os.walk

两盒软妹~` 提交于 2019-12-18 09:13:39
问题 I have set up the following directory: +---main | | | +---sub1 | | file1.xlsx | | | +---sub2 | | file2.xlsx | | | \---sub3 | file3.xlsx I want to access each file and compute the mean value of its A1:A10 cells, but while file1.xlsx exists, I get this error: IOError: [Errno 2] No such file or directory: 'file1.xlsx' My code as of now (it is designed to iterate over many "main" directories): import os from openpyxl import load_workbook directoryPath=r'C:\Users\MyName\Desktop\MainFolder' os

Renaming A Running Process' File Image On Windows

旧巷老猫 提交于 2019-12-18 09:07:08
问题 I have a Windows service application on Vista SP1 and I've found that users are renaming its executable file (while it's running) and then rebooting, thus causing it to fail to start on next bootup because the service manager can no longer find the exe file since it's been renamed. I seem to recall that with older versions of Windows you couldn't do this because the OS placed a lock on the file. Even with Vista SP1 I still cannot copy over the existing file when it's running - Windows reports

matlab iterative filenames for saving

南笙酒味 提交于 2019-12-18 08:57:38
问题 this question about matlab: i'm running a loop and each iteration a new set of data is produced, and I want it to be saved in a new file each time. I also overwrite old files by changing the name. Looks like this: name_each_iter = strrep(some_source,'.string.mat','string_new.(j).mat') and what I#m struggling here is the iteration so that I obtain files: ...string_new.1.mat ...string_new.2.mat etc. I was trying with various combination of () [] {} as well as 'string_new.'j'.mat' (which gave

Obtain filename from file pointer in C [duplicate]

删除回忆录丶 提交于 2019-12-18 08:33:59
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Getting Filename from file descriptor in C How get fileName having FILE*? Is there any way where I can find the file_name from a file-pointer in C? fp = fopen(file,"r"); From fp, is it possible to get the file name which I have opened? 回答1: I believe not, because a file* could be to something that doesn't even have a name. There might be a platform dependent way, depending I. Your system, so if you don't care

java filenames filter pattern [duplicate]

℡╲_俬逩灬. 提交于 2019-12-18 04:45:11
问题 This question already has answers here : How to find files that match a wildcard string in Java? (16 answers) Closed 6 years ago . I need to implement File[] files = getFiles( String folderName, String ptrn ); Where ptrn is a command prompt style pattern like "*2010*.txt" I'm familar with FilenameFilter class, but can't implement public boolean accept(File dir, String filename) because String.matches() doesn't accept such patterns. Thanks! 回答1: The String#matches() accepts regular expression

Python: getting filename case as stored in Windows?

吃可爱长大的小学妹 提交于 2019-12-18 04:34:06
问题 Though Windows is case insensitive, it does preserve case in filenames. In Python, is there any way to get a filename with case as it is stored on the file system? E.g., in a Python program I have filename = "texas.txt", but want to know that it's actually stored "TEXAS.txt" on the file system, even if this is inconsequential for various file operations. 回答1: Here's the simplest way to do it: >>> import win32api >>> win32api.GetLongPathName(win32api.GetShortPathName('texas.txt'))) 'TEXAS.txt'

Get name of file that is including a PHP script

梦想的初衷 提交于 2019-12-18 03:51:54
问题 Here is an example of what I am trying to do: index.php <ul><?php include("list.php") ?></ul> list.php <?php if (PAGE_NAME is index.php) { //Do something } else { //Do something } ?> How can I get the name of the file that is including the list.php script (PAGE_NAME)? I have tried basename(__FILE__) , but that gives me list.php . 回答1: $_SERVER["PHP_SELF"]; returns what you want 回答2: If you really need to know what file the current one has been included from - this is the solution: $trace =

Tab-completion of filenames as arguments for MATLAB scripts

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 22:50:10
问题 We all know MATLAB provides tab-completion for filenames used as arguments in MATLAB function like importdata , imread . How do we do that for the functions we create? EDIT: Displays the files and folders in the current directory. 回答1: Caution: unsupported hack here. Take a look at the file toolbox\local\TC.xml in your Matlab installation. This appears to contain the argument type mappings for tab completion. (I found this by just grepping the Matlab installation for "imread" in R2009b.)

Applescript: Get filenames in folder without extension

寵の児 提交于 2019-12-17 21:02:36
问题 I can get the names of all files in a folder by doing this: tell application "Finder" set myFiles to name of every file of somePath end tell How can I change the strings in myFiles so that they do not include the file extension? I could for example get {"foo.mov", "bar.mov"} , but would like to have {"foo", "bar"} . Current solution Based on the accepted answer I came up with the code below. Let me know if it can be made cleaner or more efficient somehow. -- Gets a list of filenames from the