filenames

C# Get filename from mail attachements

好久不见. 提交于 2019-12-10 03:10:37
问题 I have a simple C# app that send SMTP emails (using System.Net.Mail classes). After sending (emailing) a MailMessage object I want to iterate through the list of the attachments and delete the original files associated with those attachments... but I am having a hard time finding the full file path associated with each attachment - without keeping my own collection of attachment filepaths. There has got to be a good way to extract the full file path from the attachment object. I know this has

Python IOError exception when creating a long file

ぐ巨炮叔叔 提交于 2019-12-10 03:01:12
问题 I get an IOError shown below when trying to open a new file using "open (fname, 'w+')". The complete error message is below. The file does not exist, but I verified using "os.access(dir_name, os.W_OK)" and "os.path.exists (dir_name)" that the parent directory for the file does exist. I am wondering if the file name is just too long for Windows, or if I am doing something wrong. Any tips would be appreciated. Thank you very much. Error message: IOError: [Errno 2] No such file or directory: 'C:

I want to echo __FILE__ name without path. I just want to name of page for example: index.php

柔情痞子 提交于 2019-12-10 02:37:02
问题 echo __ FILE __ ; gives me: C:\EasyPHP-DevServer-13.1VC9\data\localweb\projects\FOLDERNAME\index.php I just want to get file name without its path. I want to get index.php on its own. Any ideas? 回答1: This will do what you want: echo basename(__FILE__); 回答2: Use pathinfo() function, then you can get filename via basename $path_parts = pathinfo(__FILE__); echo $path_parts['basename']; 来源: https://stackoverflow.com/questions/18069200/i-want-to-echo-file-name-without-path-i-just-want-to-name-of

What should I name my files with generic class definitions?

℡╲_俬逩灬. 提交于 2019-12-10 01:48:00
问题 I'm writing a couple of classes that all have generic type arguments, but I need to overload the classes because I need a different number of arguments in different scenarios. Basically, I have public class MyGenericClass<T> { ... } public class MyGenericClass<T, K> { ... } public class MyGenericClass<T, K, L> { ... } // it could go on forever, but it won't... I want them all in the same namespace, but in one source file per class. What should I name the files? Is there a best practice? 回答1:

How to Get File Name from Upload Form Using jQuery?

百般思念 提交于 2019-12-09 14:57:42
问题 I want to get the file name of the uploaded file using jQuery. But the problem, I got the fake path and file name, instead of the file name only. This is my form. <form action="" method="post"> <input type="file" name="uploadFile" id="uploadFile" /> <input type="submit" name="submit" value="Upload" id="inputSubmit" /> </form> And the jQuery is like this $(document).ready(function(){ $('#inputSubmit').click(function(){ alert($('#uploadFile').val()); }); }); I use Chrome and got this in the

Make Django return response as a “different filename”

风流意气都作罢 提交于 2019-12-09 14:19:57
问题 I have a Django view which returns an HttpResponse with a special MIME type to make the user's browser "download" the file instead of view it in the browser. The problem is that the default filename that the response will be saved as is the URL which the user tried to access. Is there any way to include a default filename in the HttpResponse object or do I have to redirect to a different URL to make this happen? 回答1: There's a relevant example in the docs: from django.http import HttpResponse

handling filename* parameters with spaces via RFC 5987 results in '+' in filenames

谁都会走 提交于 2019-12-09 12:41:33
问题 I have some legacy code I am dealing with (so no I can't just use a URL with an encoded filename component) that allows a user to download a file from our website. Since our filenames are often in many different languages they are all stored as UTF-8. I wrote some code to handle the RFC5987 conversion to a proper filename* parameter. This works great until I have a filename with non-ascii characters and spaces. Per RFC, the space character is not part of attr_char so it gets encoded as %20. I

RegEx pattern in glob function

左心房为你撑大大i 提交于 2019-12-09 05:59:53
问题 I recive a filename in a function. I want to return all files similar to this file (by filename) from other directory. I wrote this: $thumbDir = $this->files_path.'thumbs/'; $toglob = $thumbDir.pathinfo($name, PATHINFO_FILENAME ).'_[0-9]+\x[0-9]+_thb.'.pathinfo($name, PATHINFO_EXTENSION); foreach (glob($toglob) as $key => $value) { echo $value; } But it doesn't work. I search files which their filename is: oldFileName_[one or more digits]x[one or more digits]_thb.oldFileNameExtension I will

How to get file name of an icon file in a folder for creating/updating desktop.ini for folder(s)?

岁酱吖の 提交于 2019-12-09 03:43:38
问题 I need help returning the file name of a file located in a folder. I have read other questions asked a few times and the answer seems to be: for /d %F in (*.*) do echo %~nxF Although this seems to work for everyone else, when I run this within a batch file it has an exception and states that '~nxF' is not expected at this time. What I am trying to do is create a batch file that will read the icon file name, then enter the specific information into desktop.ini and finally create that file with

Extract files with invalid characters in filename with Python

给你一囗甜甜゛ 提交于 2019-12-09 00:52:11
问题 I use python's zipfile module to extract a .zip archive (Let's take this file at http://img.dafont.com/dl/?f=akvaleir for example.) f = zipfile.ZipFile('akvaleir.zip', 'r') for fileinfo in f.infolist(): print fileinfo.filename f.extract(fileinfo, '.') Its output: Akval�ir_Normal_v2007.ttf Akval�ir, La police - The Font - Fr - En.pdf Both files are unaccessable after extraction because there are invalid encoded characters in their filenames. The problem is zipfile module doesn't have an option